Which function can be used?

1 回表示 (過去 30 日間)
adrooney
adrooney 2014 年 10 月 5 日
コメント済み: adrooney 2014 年 10 月 5 日
I have a function dA/dt= k(2-2.374A)/2.12
can I use ode45 here?

採用された回答

adrooney
adrooney 2014 年 10 月 5 日
編集済み: Jan 2014 年 10 月 5 日
Thanks for the answer, also If I have a quadratic expression on the rhs will this work. I tried to write like this. will this work too?
X=zeros (1,1000);
time =0:0.05:50;
k=0.095;
for i=2:1000
X(i) = (k*(0.305*X(i-1)^2)-(0.554X(i-1))+0.249)*0.05)+X(i-1);
end
plot (time,X)
hold on
plot(time25, alpha25)
end
  2 件のコメント
Jan
Jan 2014 年 10 月 5 日
I've formatted the code.
I guess there is a missing * in "0.554X".
I do not see a connection to the original question - where is teh ODE45 call?
adrooney
adrooney 2014 年 10 月 5 日
I'll explain you the actual problem. There is function dX/dt = k*f1(t)*f2(t) I substituted the equations of f1 and f2 and ended up with an quadratic equation. dX/dt = k*((0.305*X^2)-(0.554*X)+0.249)
now I need to extrapolate X with different values of time t. I used a for loop to extrapolate with increments of 0.05hr. So how should I approach the problem and I wrote the above code for the values of extrapolated values of X. Now when I run the code it says error in using plot. vector length must be equal. I don't know how to resolve this. Please help me with this and it would be of great help .:) Thank you

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

その他の回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2014 年 10 月 5 日
編集済み: Titus Edelhofer 2014 年 10 月 5 日
Hi Dinesh,
yes you can. Implement the right hand side of your equation as a function of the form
function dA = f(t,A)
and pass that to ode45.
Titus

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by