matlab 总是报错,问题不难但就是解决不了.function [xR yR]=reference_1(t);r=0.2165; t=0:0.0001:0.5; Phi=4*pi*t.^2;x=r*cos(Phi); y=r*sin(Phi)x1=diff(x,t,2);y1=diff(y,t,2);plot(t,x1,'k');hold on;plot(t,y1,':k');grid这是报错信息,Error
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 17:28:25
matlab 总是报错,问题不难但就是解决不了.function [xR yR]=reference_1(t);r=0.2165; t=0:0.0001:0.5; Phi=4*pi*t.^2;x=r*cos(Phi); y=r*sin(Phi)x1=diff(x,t,2);y1=diff(y,t,2);plot(t,x1,'k');hold on;plot(t,y1,':k');grid这是报错信息,Error
matlab 总是报错,问题不难但就是解决不了.
function [xR yR]=reference_1(t);
r=0.2165;
t=0:0.0001:0.5;
Phi=4*pi*t.^2;
x=r*cos(Phi);
y=r*sin(Phi)
x1=diff(x,t,2);
y1=diff(y,t,2);
plot(t,x1,'k');
hold on;
plot(t,y1,':k');
grid
这是报错信息,
Error using ==> diff
Difference order N must be a positive integer scalar.
Error in ==> reference_1 at 7
x1=diff(x,t,2)
matlab 总是报错,问题不难但就是解决不了.function [xR yR]=reference_1(t);r=0.2165; t=0:0.0001:0.5; Phi=4*pi*t.^2;x=r*cos(Phi); y=r*sin(Phi)x1=diff(x,t,2);y1=diff(y,t,2);plot(t,x1,'k');hold on;plot(t,y1,':k');grid这是报错信息,Error
这个到挺简单,主要原因是函数diff的使用方法问题,它本身是个关于符号运算的函数
所以中间的变量t是多余的
把
x1=diff(x,t,2);
y1=diff(y,t,2);
改为
x1=diff(x,2);
y1=diff(y,2);
问题将会得以解决