xichyu
2015-03-16, 09:56
MATLAB有错吗?
(1)dx=[dx(1);dx(2);dx(3);dx(4);dx(5);dx(6)]; %这一句和书上一样啊?
(2)[t,x]=ode45('ODE45_fun',tspan,x0); %和书上也是一样啊
(3)另外不懂:
The element type "name" must be terminated by the matching end-tag "</name>".
Could not parse the file: d:\matlab7\toolbox\ccslink\ccslink\info.xml
(4)实在不懂【求解释,谢谢】:
Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
点击 funfun\private\odearguments at 110 后出现110-118:
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
[m,n] = size(f0);
if n > 1
error('MATLABdearguments:FoMustReturnCol',...
[funstring(ode) ' must return a column vector.'])
elseif m ~= neq
msg = sprintf('an initial condition vector of length %d.',m);
error('MATLABdearguments:SizeIC', ['Solving ' funstring(ode) ' requires ' msg]);
end
(5)实在不懂【求解释,谢谢】:
Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
点击 funfun\private\odearguments at 110 后出现173-178:
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
options, threshold, rtol, normcontrol, normy, hmax, htry, htspan, ...
dataType] = ...
odearguments(FcnHandlesUsed, solver_name, odeFcn, tspan, y0, ...
options, varargin);
nfevals = nfevals + 1;
以下是该程序
ODE45_fun:
function dx=ODE45_fun(t,x)
a1=1;a2=1;e1=9;e2=7;f1=56;f2=98;g1=76;g2=665;
a=a1+a2;
e=e1+e2;
f=f1+f2;
g=g1+g2;
dx(1)=x(3)-x(2)+x(4)*x(2)-2*x(5)*x(2)-x(2)*x(2)-x(5)-e-f-g;
dx(2)=x(1)-x(3)+x(4)*x(2)-x(2)*x(2)-x(5)*x(5)-x(5)*x(2)-e*f-g;
dx(3)=x(2)-x(1)+x(5)*x(1)-x(4)*x(3)+x(3)+x(4)+e*g+f;
x(6)=x(4)*x(5)+x(2)*x(3)+e*f+e*g;
dx(4)=x(5)*a+x(3)*x(1)+x(3)+e*f*g*x(6)
dx(5)=x(4)*a+x(2)*x(1)-e*f*x(1)-x(2)*x(2)*x(5)-x(2)*x(5)*x(5)-e*f-f*g
dx=[dx(1);dx(2);dx(3);dx(4);dx(5);dx(6)];
ODE45_main:
tspan=[0,10];
x0=[0;0.1;2;0;0.1;2];
[t,x]=ode45('ODE45_fun',tspan,x0);
data=[t,x];
save ODE45_data.txt data -ascii
subplot(2,3,1),plot(t,x(1))
subplot(2,3,2),plot(t,x(2))
subplot(2,3,3),plot(t,x(3))
subplot(2,3,4),plot(t,x(4))
subplot(2,3,5),plot(t,x(5))
subplot(2,3,6),plot(t,x(6))3352
(1)dx=[dx(1);dx(2);dx(3);dx(4);dx(5);dx(6)]; %这一句和书上一样啊?
(2)[t,x]=ode45('ODE45_fun',tspan,x0); %和书上也是一样啊
(3)另外不懂:
The element type "name" must be terminated by the matching end-tag "</name>".
Could not parse the file: d:\matlab7\toolbox\ccslink\ccslink\info.xml
(4)实在不懂【求解释,谢谢】:
Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
点击 funfun\private\odearguments at 110 后出现110-118:
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
[m,n] = size(f0);
if n > 1
error('MATLABdearguments:FoMustReturnCol',...
[funstring(ode) ' must return a column vector.'])
elseif m ~= neq
msg = sprintf('an initial condition vector of length %d.',m);
error('MATLABdearguments:SizeIC', ['Solving ' funstring(ode) ' requires ' msg]);
end
(5)实在不懂【求解释,谢谢】:
Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
点击 funfun\private\odearguments at 110 后出现173-178:
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...
options, threshold, rtol, normcontrol, normy, hmax, htry, htspan, ...
dataType] = ...
odearguments(FcnHandlesUsed, solver_name, odeFcn, tspan, y0, ...
options, varargin);
nfevals = nfevals + 1;
以下是该程序
ODE45_fun:
function dx=ODE45_fun(t,x)
a1=1;a2=1;e1=9;e2=7;f1=56;f2=98;g1=76;g2=665;
a=a1+a2;
e=e1+e2;
f=f1+f2;
g=g1+g2;
dx(1)=x(3)-x(2)+x(4)*x(2)-2*x(5)*x(2)-x(2)*x(2)-x(5)-e-f-g;
dx(2)=x(1)-x(3)+x(4)*x(2)-x(2)*x(2)-x(5)*x(5)-x(5)*x(2)-e*f-g;
dx(3)=x(2)-x(1)+x(5)*x(1)-x(4)*x(3)+x(3)+x(4)+e*g+f;
x(6)=x(4)*x(5)+x(2)*x(3)+e*f+e*g;
dx(4)=x(5)*a+x(3)*x(1)+x(3)+e*f*g*x(6)
dx(5)=x(4)*a+x(2)*x(1)-e*f*x(1)-x(2)*x(2)*x(5)-x(2)*x(5)*x(5)-e*f-f*g
dx=[dx(1);dx(2);dx(3);dx(4);dx(5);dx(6)];
ODE45_main:
tspan=[0,10];
x0=[0;0.1;2;0;0.1;2];
[t,x]=ode45('ODE45_fun',tspan,x0);
data=[t,x];
save ODE45_data.txt data -ascii
subplot(2,3,1),plot(t,x(1))
subplot(2,3,2),plot(t,x(2))
subplot(2,3,3),plot(t,x(3))
subplot(2,3,4),plot(t,x(4))
subplot(2,3,5),plot(t,x(5))
subplot(2,3,6),plot(t,x(6))3352