马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
以下是我编的一个程序:
function LinearResponse
m0=0.46; r=13.5; w=200*2*3.14;m=3.76; f=578;k=10;
tspan=linspace(0,30,6000); sampint=tspan(2);
options=odeset('RelTol',1e-8,'AbsTol',[1e-8,1e-8]);
[t,x]=ode45(@ForcedOscillatorl,tspan,[0 0]',options,m0,r,w,m,f,k);
figure(1); plot(t,x(:,1)); axis([0 30,-1,1]); xlabel('\tau'); ylabel('x(\tau)');
yy=x(:,1);
funtion xdot=ForcedOscillatorl(t,x,m0,r,w,m,f,k)
xdot=[x(2);-f*x(2)/(m0+m)-k*x(1)/(m0+m)+m0*r*cos(w*t)*w^2/(m0+m)];
可是运行不了结果,总提示错误,不知道为什么:
Warning: feval on script names will not work, or may work differently,
in a future version of MATLAB. To make your code insensitive to any change
and to suppress this warning message:
- Either change the script to a function.
- Or use eval instead of feval.
The script file in question is ForcedOscillatorl.
> In funfun\private\odearguments at 110
In ode45 at 173
In LinearResponse at 8
??? Attempt to execute SCRIPT ForcedOscillatorl as a function:
D:\我的文档\MATLAB\ForcedOscillatorl.m
Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ==> LinearResponse at 8
[t,x]=ode45(@ForcedOscillatorl,tspan,[0 0]',options,m0,r,w,m,f,k);
请多多指教,谢谢!
[ 本帖最后由 ChaChing 于 2010-4-7 00:02 编辑 ] |