How to call differential equations inside function, and solve it ?

조회 수: 1 (최근 30일)
P K
P K 2019년 1월 9일
댓글: madhan ravi 2019년 1월 11일
I am having a code, which has symbolic variables. First,I am creating a system of coupleld differential equations through loop and then applying ODE15S to solve it. The equations are(one of the case)
function dCdT =solveode(t,C,A,T,L.......)
dCdt=zeros(6,1);
dCdT(1)=-C(1)*((3*A)/500 + (3*L)/1000 + (3*T)/500);
dCdT(2)=(3*C(1)^2)/500 - C(2)*((9*A)/1000 + (3*L)/1000 + (3*T)/500);
dCdT(3)=(3*C(1)*C(2))/1000 - C(3)*((3*A)/250 + (3*L)/1000 + (3*T)/500);
dCdT(4)=(3*C(2)^2)/1000 - C(4)*((3*A)/250 + (3*L)/1000 + (3*T)/500) + (9*C(1)*C(3))/500 + (3*C(1)*C(4))/500;
dCdT(5)=(3*C(1)*C(2))/250;
dCdT(6)=(3*C(2)^2)/500;
end
But these i have written manually. But i want to call them through a loop inside the function. I am trying to do this because, these set of differential equations would vary according to some other variable. Can some one suggest how to acheive this ?
  댓글 수: 3
P K
P K 2019년 1월 9일
Ok walter, thanks !! I would look at them.
madhan ravi
madhan ravi 2019년 1월 11일
ok it's good that you have asked a new question but there is no need to close this question, leave it open.

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

답변 (1개)

madhan ravi
madhan ravi 2019년 1월 9일
편집: madhan ravi 2019년 1월 9일
for A=A
ode45(...) so A changes in every iteration likewise vary the other parameters too
end
  댓글 수: 3
madhan ravi
madhan ravi 2019년 1월 9일
See https://www.mathworks.com/matlabcentral/answers/436035-function-with-different-parameters#answer_352662 the parameter e changes in each iteration likewise you can adapt it here for instance A , L or whatever.
P K
P K 2019년 1월 11일
Hello, since I couldn't apply this to my question i would start a new thread and put my question there.

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

카테고리

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