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

>> 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')
>>

 採用された回答

0 投票

仅供参考
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 件)

カテゴリ

ヘルプ センター および File Exchange外部语言接口 についてさらに検索

Community Treasure Hunt

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

Start Hunting!