using "for loop" to solve 5 different coupled differential equation.
7 ビュー (過去 30 日間)
古いコメントを表示
syms A(t) O(t)
a = 0.6;
n = 0.05;
tc = 10E-9;
r = 1.5;
F = 1;
N = 5;
for i = 1:N
ode1 = diff(A(i)) == (-1/(2*tc)).*(1 - r/(1+ (A(i)^2)./F)).*A(i) + (n/(2*tc)).*((cos(O(i))).*A(i+1) + (cos(O(i-1))).*A(i-1)) ;
ode2 = diff(O(i)) == (a./(2*tc)).*( r/(1 + (A(i+1)^2)./F) - r/(1 + (A(i)^2)./F) ) + (n/(2*tc)).*(((A(i+2)./A(i+1)).*sin(O(i+1))) - (A(i+1)./A(i) + A(i)./A(i+1) ).*sin(O(i)) + (A(i-1)./A(i)).*sin(O(i-1)));
odes = [ode1(i); ode2(i)]
S(i) = dsolve(odes(i))
A(i)Sol(t) = S.A(i)
O(i)Sol(t) = S.O(i)
[A(i)Sol(t),O(i)Sol(t)] = dsolve(odes(i))
conds = [1; 0];
[A(i)Sol(t),O(i)Sol(t)] = dsolve(odes(i),conds)
fplot(A(i)Sol)
hold on
fplot(O(i)Sol)
grid on
end
I want to use for loop so it will solve 5 couple differential equation,
first it will take i =1 to solve A(1) and O(1) and then i want to plot A(1) vs time. i want to do this till A(5).
and i want to put a condition in which is like if i >=5 then the i+1 becomes 1 and i+2 becomes 2.
1 件のコメント
Torsten
2022 年 8 月 2 日
Your equations cannot be solved using "dsolve" because they are far too compliciated.
Either use Walter's suggestion to prepare the function used for ODE45 by MATLAB's "odefunction"
or define your function to be used for ODE45 directly.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Equation Solving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
