Solving a system of differential equation

1 回表示 (過去 30 日間)
Abhishek Varma
Abhishek Varma 2020 年 10 月 19 日
コメント済み: Ameer Hamza 2020 年 10 月 20 日
Can someone tell me why the answers are coming as 'NaN'?
Also in the first for loop, by writing dEs in descritized form (line 22 and 23) my aim is to find (dEs/dt) and use the value of Es in line 23. Also,after this loop, the final values of El and Es needs to be carried over to next loop. I have coded this as best as i know. Can someone tell me how i can find d(Es)/dt directly instead of discretizing it?
  7 件のコメント
Abhishek Varma
Abhishek Varma 2020 年 10 月 20 日
i am using t as state function because i need to find delta t to find the d(Eendo,s)/dt term in discretized form. I know its not the most effective way, but since im not very well versed in matlab i dont know how to do it otherwise. I was hoping to find a way to code it by using the same ode45 to solve for Es also while solving the concentration terms. But also, once t<300 loop is over, the value of Es needs to be carried over to the next t>=300 loop, where we have the equation to find Es directly, but at this time, the value of Es must be updated from the previous itertation but with a new equation.
Ameer Hamza
Ameer Hamza 2020 年 10 月 20 日
But a scheme like this will not work as expected. ode45() does not do one calculation in each iteration. It is an adaptive step-size algorithm, and the point moves forward and backward several times in each iteration for ode45 to decide what should be a good step length. So You might be expecting that it is the value from the previous iteration, but is not exactly that.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by