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

1 visualización (últimos 30 días)
皇家国际在线开户【微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);
>> 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')
>>

Respuesta aceptada

皇家国际注册开户【微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')

Más respuestas (0)

Categorías

Más información sobre 外部语言接口 en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!