24小时热门版块排行榜    

查看: 1173  |  回复: 9
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

wyjjf

新虫 (正式写手)

[交流] MATLAB求助 已有1人参与

【m.file】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;        % 就是x(6)  而非dx(6)
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)];
【m.file】DE45_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))

>> ODE45_main

dx =

  1.0e+010 *

    0.0000    0.0000   -0.0000   -2.6146


dx =

  1.0e+010 *

    0.0000    0.0000   -0.0000   -2.6146    0.0000

??? Attempted to access dx(6); index out of bounds because numel(dx)=5.

Error in ==> ODE45_fun at 14
dx=[dx(1);dx(2);dx(3);dx(4);dx(5);dx(6)];
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, ...

Error in ==> ODE45_main at 3
[t,x]=ode45('ODE45_fun',tspan,x0);

MATLAB求助
六元方程组怎么用MATLAB编辑程序?.jpg
MATLAB求助-1
六元方程组怎么用MATLAB编辑程序?.jpg
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wyjjf

新虫 (正式写手)

empty vector.是什么意思? 还有
passing empty for the initial condition.
3楼2015-03-14 17:25:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 10 个回答

wyjjf

新虫 (正式写手)

一个老外给的回答
What is

x0=[0:0.1:2:0:0.1:2];     原来写的是x0=[0:0.1:2:0:0.1:2];
supposed to mean? On my version of matlab (2015a) it does not give me any warning but it creates an empty vector.

I suspect it's the cause of the warning and ultimately the cause of the error since you're passing empty for the initial condition.

希望论坛的大神多多帮忙!
2楼2015-03-14 17:24:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

信彼南山

木虫 (著名写手)


小木虫: 金币+0.5, 给个红包,谢谢回帖
你这程序编的,符号跟方程还不一致,看起来好累的
你这里面Y只出现在方程4和方程5里面,可以考虑吧Y消去吧,变成5个方程5个变量的是不是能容易点
4楼2015-03-15 01:16:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

信彼南山

木虫 (著名写手)


小木虫: 金币+0.5, 给个红包,谢谢回帖
你这程序肯定有问题,跟你图上的方程完全不一样么。
而且方程咋还有那么多dx = 。。。 = 0

5楼2015-03-15 02:11:05
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见