solving many linear differential equations through ODE solver.

조회 수: 3 (최근 30일)
P K
P K 2019년 1월 6일
댓글: P K 2019년 1월 17일
I am not sure whether my approach is good or not, because my simulation takes ENORMOUS amount of time in execution.
I have a general form of differential equations , which contain summation signs, and it is suumed over i,j. When i,j varies, the number of variables in the differential equations also changed. Index i and j are related with a relation.That means the number of variable are also dependent on i & j .So, here is what i am planning
syms H(i,j) % generalized variable
% Storing the varaibles
n=10 %number of variables (This would change)
for i=1:n
for j=1:n
if i+j==... && i/2==...
T(i,j)=H(i,j) % Store the variable
end
end
%% Now i am using T as variable, and using 4 "for loops" to form the differential equations.
% Then solve it through ODE .
The code is working for small value of "n". But it takes 3 days when n=50. And runs out of memory when n=60. How can i optimize my code and avoid syms ? I can observe, that the major problem is in creating the equations.Am i doing wrong in creating the variables like this ? Is there any way to overcome this ?

채택된 답변

Torsten
Torsten 2019년 1월 7일
Don't use symbolic variables together with "many" differential equations.
Use a numerical ODE integrator instead (e.g. ODE15S).
  댓글 수: 11
Torsten
Torsten 2019년 1월 16일
You didn't write the differential equations for P and P1.
These have to be inserted in the lines
dP = ?
dPn(1) = ?
Further, "kp" has to be specified at the beginning of the function.
P K
P K 2019년 1월 17일
Thanks Torsten,Madhan ravi and Bjorn Gustavsson. I really appreciate your help.It saved a lot of computation time.
Since I am not from programming background, It took so long for me in accepting your answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by