蜜游儿 发表于 2010-3-31 16:07

请教一个关于解二阶常系数非齐次方程的问题

以下是我编的一个程序:
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',);
=ode45(@ForcedOscillatorl,tspan,',options,m0,r,w,m,f,k);
figure(1); plot(t,x(:,1)); axis(); xlabel('\tau'); ylabel('x(\tau)');
yy=x(:,1);

funtion xdot=ForcedOscillatorl(t,x,m0,r,w,m,f,k)
xdot=;

可是运行不了结果,总提示错误,不知道为什么:
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
=ode45(@ForcedOscillatorl,tspan,',options,m0,r,w,m,f,k);

请多多指教,谢谢!

[ 本帖最后由 ChaChing 于 2010-4-7 00:02 编辑 ]

maigicku 发表于 2010-3-31 16:35

将函数文件里的“funtion”改为“function”
将主程序里的“function LinearResponse”去掉

蜜游儿 发表于 2010-3-31 16:52

回复 板凳 maigicku 的帖子

还是不对
??? Error: File: LinearResponse.m Line: 1 Column: 9
Expression or statement is incomplete or incorrect.

maigicku 发表于 2010-4-6 16:35

程序如下:

function xdot=ForcedOscillatorl(t,x,m0,r,w,m,f1,k)
xdot=;
end



clear;clc
m0=0.46;
r=13.5;
w=200*2*3.14;
m=3.76;
f1=578;
k=10;
tspan=linspace(0,30,100);
sampint=tspan(2);
options=odeset('RelTol',1e-8,'AbsTol',);
=ode45(@ForcedOscillatorl,tspan,,options,m0,r,w,m,f1,k);
figure(1);
plot(t,x(:,1));
axis();
xlabel('\tau');
ylabel('x(\tau)');
yy=x(:,1);


建议将tapan的取值个数减小一些,要不运行时间太长。。。还有将ode45中的“'”改为“”

[ 本帖最后由 maigicku 于 2010-4-6 16:54 编辑 ]

蜜游儿 发表于 2010-4-8 17:52

回复 地板 maigicku 的帖子

非常感谢!
页: [1]
查看完整版本: 请教一个关于解二阶常系数非齐次方程的问题