clear;
clc;
str=[];
x=[10 20 30];
y=[1 4 8];
t=0:0.5:10;
colorstring={'y','m','c','r','g','b','k','r.','bo','cx'};
for i=1:3
for j=1:3
figure(1);
a=sin(t*x(i)*y(j));
plot(t,a,colorstring{(i-1)*3+j});
hold on;
figure(2);
b=cos(t*x(i)*y(j));
plot(t,b,colorstring{(i-1)*3+j});
hold on;
str=[str;['i=',num2str(x(i)),',j=',num2str(y(j))]];
end
end
figure(1);
legend(str);
figure(2);
legend(str);
clear;
clc;
str=[];
x=[10 20 30];
y=[1 4 8];
t=0:0.5:10;
for i=1:3
for j=1:3
figure(1);
a=sin(t*x(i)*y(j));
plot(t,a,'g');
hold on;
figure(2);
b=cos(t*x(i)*y(j));
plot(t,b,'r');
hold on;
str=[str;['i=',num2str(x(i)),',j=',num2str(y(j))]];
end
end
figure(1);
legend(str);
figure(2);
legend(str);
你的col是一个cell数组,应该用花括号,即col{2}