Solving System ODE with ode45
1 次查看(过去 30 天)
显示 更早的评论
Hi All, I'm trying to solve a system ODE with ode45. I get this error for my code:
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Any help is appreciated. I have attached the m.files
采纳的回答
bio lim
2016-11-30
编辑:bio lim
2016-11-30
With first look, in your function, there are many undefined variables, that are X0, y0, z0, and Ap0.
10 个评论
bio lim
2016-11-30
I see. Defining unnecessary variables is the first thing you should avoid.
You have defined:
Tg=1;
Tr=2;
ProInh2=3;
HGlnInh=4;
Inh=5;
TrTg=6;
p2_Tr=7;
and then:
x0(Tg)=1;
x0(Tr)=1;
x0(ProInh2)=0;
x0(HGlnInh)=1;
x0(Inh)=0;
x0(TrTg)=1;
x0(p2_Tr)=0;
These are simple things you should avoid. Just set x0(1) = 1, or even better x0 = [1 . . . ], and make a comment saying the first element of your initial condition is Tg. Declaring many variables like this makes your program look very complicated and tiring to look at, especially for debugging. For example, when I was looking at your function definition, I had hard time following it due to the number of variables, and which index is being manipulated in your operations.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!