发布网友 发布时间:2022-04-23 22:53
共2个回答
热心网友 时间:2023-09-14 20:33
用for循环实现当然也可以,不过用位运算的话,效率会更高
function yangben=read_yangben()
f1=fopen( 'data.txt','r');
yangben=textscan(f1,'%d%d%d',1400,'delimiter',',' );
fclose(f1);
x=yangben{1};
y=yangben{2};
z=yangben{3};
ind1=z==0;
ind2=z==1;
ind3=z==2;
plot(x(ind1),y(ind1),'*k','markersize',10);
hold on;
plot(x(ind2),y(ind2),'*y','markersize',10);
plot(x(ind3),y(ind3),'*b','markersize',10);
end
热心网友 时间:2023-09-14 20:33
function yangben=read_yangben()
f1=fopen( 'data.txt','r');
yangben=textscan(f1,'%d%d%d',1400,'delimiter',',' );
fclose(f1);
x=yangben{1};
y=yangben{2};
z=yangben{3};
k=length(x);
hold on
for i=1:k
switch (z(i))
case 0
plot(x(i),y(i),'ok')
case 1
plot(x(i),y(i),'oy');
case 2
plot(x(i),y(i),'ob');
end
end
end