Function definitions are not permitted at the prompt or in scripts.请高手帮我看看这段里面的错误syms G H x0 u0 N Tfunction [t,xx]=diffstate(G,H,x0,u0,N,T) xk=x0;u=u0;t=0;for k=1:Nxk=G*xk+H*u;x(:k)=x0;xx=[x0,x];t=[t,k*T];end
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 17:09:51
![Function definitions are not permitted at the prompt or in scripts.请高手帮我看看这段里面的错误syms G H x0 u0 N Tfunction [t,xx]=diffstate(G,H,x0,u0,N,T) xk=x0;u=u0;t=0;for k=1:Nxk=G*xk+H*u;x(:k)=x0;xx=[x0,x];t=[t,k*T];end](/uploads/image/z/11575333-37-3.jpg?t=Function+definitions+are+not+permitted+at+the+prompt+or+in+scripts.%E8%AF%B7%E9%AB%98%E6%89%8B%E5%B8%AE%E6%88%91%E7%9C%8B%E7%9C%8B%E8%BF%99%E6%AE%B5%E9%87%8C%E9%9D%A2%E7%9A%84%E9%94%99%E8%AF%AFsyms+G+H+x0+u0+N+Tfunction+%5Bt%2Cxx%5D%3Ddiffstate%28G%2CH%2Cx0%2Cu0%2CN%2CT%29+xk%3Dx0%3Bu%3Du0%3Bt%3D0%3Bfor+k%3D1%3ANxk%3DG%2Axk%2BH%2Au%3Bx%28%3Ak%29%3Dx0%3Bxx%3D%5Bx0%2Cx%5D%3Bt%3D%5Bt%2Ck%2AT%5D%3Bend)
Function definitions are not permitted at the prompt or in scripts.请高手帮我看看这段里面的错误syms G H x0 u0 N Tfunction [t,xx]=diffstate(G,H,x0,u0,N,T) xk=x0;u=u0;t=0;for k=1:Nxk=G*xk+H*u;x(:k)=x0;xx=[x0,x];t=[t,k*T];end
Function definitions are not permitted at the prompt or in scripts.请高手帮我看看这段里面的错误
syms G H x0 u0 N T
function [t,xx]=diffstate(G,H,x0,u0,N,T)
xk=x0;u=u0;t=0;
for k=1:N
xk=G*xk+H*u;
x(:k)=x0;
xx=[x0,x];
t=[t,k*T];
end
Function definitions are not permitted at the prompt or in scripts.请高手帮我看看这段里面的错误syms G H x0 u0 N Tfunction [t,xx]=diffstate(G,H,x0,u0,N,T) xk=x0;u=u0;t=0;for k=1:Nxk=G*xk+H*u;x(:k)=x0;xx=[x0,x];t=[t,k*T];end
你把第一行删除掉就可以运行.
几点说明:
1. Matlab不支持符号运算的函数定义.
2. 如果你只是想定义一个函数,G, H, x0, u0, N, T均以数值参数输入函数,则你不需要声明它们.