Coupled Differential Equation
古いコメントを表示
Dear Friend,
I am solving a coupled differential equation in matlab to simulate the laser rate equation. The number of differential equation depends on the number of modes I will put through input, usually it is a very high number say 500-600.
I have two for loops inside another for loop.
I use the usual trick: dx/dt = Ax (say this is the differential equation)
so x2 = x1 + dt(Ax) (I solve it this way giving an initial condition on x1)
The problem is, this equation will be valid as long as abs(dx/x)<<1. And we need 'dt' for this purpose very small, which will eventually increases the iteration of my for loop. Now when I do that, I got an out of memory error.
Is there a way to get rid of it. I was thinking of extracting few outputs from the iteration (not all the output), but also it didn't work.
Thanks for your time.
-Graig
2 件のコメント
Jarrod Rivituso
2011 年 4 月 21 日
Forgive me if I misunderstand, but are you not using one of the ODE solvers?
Graig
2011 年 4 月 21 日
採用された回答
その他の回答 (3 件)
Jarrod Rivituso
2011 年 4 月 21 日
0 投票
I would recommend giving these a try:
I've never used them with the number of states you have. You may end up finding that your system is "stiff", depending on the system dynamics. In this case, you may prefer ode15s or other stiff solvers to the commonly used ode45.
Graig
2011 年 5 月 2 日
0 投票
7 件のコメント
Jarrod Rivituso
2011 年 5 月 2 日
You shouldn't need to put this in a loop just to solve a system of equations. The idea is that you tell it
- the initial conditions
- a function that returns the state derivatives
- a time span
and then it will go solve the equations for you.
Is there something else that is forcing you to use a loop?
Graig
2011 年 5 月 2 日
Andrew Newell
2011 年 5 月 2 日
I have edited my answer to take this information into account.
Graig
2011 年 5 月 4 日
Andrew Newell
2011 年 5 月 4 日
What do you mean by "above that"?
Andrew Newell
2011 年 5 月 4 日
This question is starting to sprawl and it is not clear what is going on. I recommend you accept an answer for this question and submit a new one in which you show us the code you used and describe the problem you are having.
Graig
2011 年 5 月 5 日
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!