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

2 件のコメント

bio lim
bio lim 2016 年 11 月 30 日
I don't see your .m files.
Donrad
Donrad 2016 年 11 月 30 日
Whoops. Files are now attached, thanks for the heads up.

サインインしてコメントする。

 採用された回答

bio lim
bio lim 2016 年 11 月 30 日
編集済み: bio lim 2016 年 11 月 30 日

0 投票

With first look, in your function, there are many undefined variables, that are X0, y0, z0, and Ap0.

10 件のコメント

Donrad
Donrad 2016 年 11 月 30 日
編集済み: Donrad 2016 年 11 月 30 日
But I have defined those in EnzymaticOscillationORP.m before calling the function.
%The Initial Conditions
X0=.167 ;
z0=1.5 ;
y0=0.0002;
Ap0=0.22 ;
Donrad
Donrad 2016 年 11 月 30 日
Ok, now I see I added those lines to the function file and it worked but there is a warning:
Warning: Failure at t=1.288951e-02. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.775558e-17) at time t.
should I change the RelTol?
bio lim
bio lim 2016 年 11 月 30 日
Functions do not use base workspace. They use their own workspace; which means you have to define all those variables inside the function. You can declare them as global variables, however it is highly unrecommended.
Donrad
Donrad 2016 年 11 月 30 日
I see, Thank you so much.
bio lim
bio lim 2016 年 11 月 30 日
編集済み: bio lim 2016 年 11 月 30 日
That warning is probably due to your system being stiff. I wouldn't suggest you to change the relative tolerance, though I am not sure. I suggest you to use ode15s, or ode23s.
Donrad
Donrad 2016 年 11 月 30 日
編集済み: Donrad 2016 年 11 月 30 日
I'm expecting to see an Oscillation in my system (as in the image). I used ode15s but got the same warning.
bio lim
bio lim 2016 年 11 月 30 日
I would try increasing the tolerance then, it may be too 'tight' at the moment. Otherwise, there may be a problem with your system definition.
Donrad
Donrad 2016 年 11 月 30 日
Problem was in the initial conditions. Reduced them to reasonable values but Matlab still in busy mode. I don't if the coding was efficient or not. I'm new to Matlab so I just read the documentation of ode45 and wrote the codes.
bio lim
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.
Donrad
Donrad 2016 年 11 月 30 日
Yeah, I used the proper I.Cs:
x0(Tg)=0.167;
x0(Tr)=0.0002;
x0(ProInh2)=1.5;
x0(HGlnInh)=0;
x0(Inh)=.278;
x0(TrTg)=0;
x0(p2_Tr)=0;
But no solution so far. I agree I have to code efficiently.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

質問済み:

2016 年 11 月 30 日

コメント済み:

2016 年 11 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by