问一下大家为啥出错了,是哪一步出了问题吗。

1 次查看(过去 30 天)
>> x=-pi:pi/100:pi;
y1=cos(1.*(1./cos(x)));
y2=cos(2.*(1./cos(x)));
y3=cos(3.*(1./cos(x)));
y4=cos(4.*(1./cos(x)));
y5=cos(5.*(1./cos(x)));
plot(x,y1,x,y2,x,y3,x,y4,x,y5);
legend('m=1','m=2','m=3','m=4','m=5');
title('Chebyshev');
xlabel('X'),ylabel('Y');
>> grid;
>> x=linspace(-1,1);
>> y=[];
>> for m=1:5
y=[y,cos(m*acos(x))];
end
>> plot(x,y);
Error using plot
Vectors must be the same lengths.
>> legend('m=1','m=2','m=3','m=4','m=5')
>>

采纳的回答

皇家国际注册开户【微8785092】
仅供参考
x=-pi:pi/100:pi;
y1=cos(1.*(1./cos(x)));
y2=cos(2.*(1./cos(x)));
y3=cos(3.*(1./cos(x)));
y4=cos(4.*(1./cos(x)));
y5=cos(5.*(1./cos(x)));
plot(x,y1,x,y2,x,y3,x,y4,x,y5);
legend('m=1','m=2','m=3','m=4','m=5');
title('Chebyshev');
xlabel('X'),ylabel('Y');
grid;
x=linspace(-1,1);
for m=1:5
    y(m,:)=cos(m*acos(x));
end
plot(x,y);
legend('m=1','m=2','m=3','m=4','m=5')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 外部语言接口 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!