Differential algebraic eqn solving using ode15s
์กฐํ ์: 1 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
I've a 6Differential_Equations's and 6Algebraic_Equations's, with initial condition.
when I'm excecuting the code i'm getting error, which is given in the below image.
Thanks in advance๐
global G0 N0 v0;
G0 = 1; N0 = 1; v0 = 1;
L10 = 1; L20 = 2; L30 = 3;
w10 = 0.1; w20 = 0.2; w30 = 1- w10 -w20;
for i = 1:6
mu0(i) = w10*L10^i + w20*L20^i + w30*L30^i;
end
y0 = [mu0 w10 w20 w30 L10 L20 L30];
M = [eye(6),zeros(6);zeros(6,12)];
options = odeset('Mass',M,'RelTol',1e-4,'AbsTol',1e-6*ones(1,12));
tspan = linspace(0,1,10000);
[t,m] = ode15s(@myfun,tspan,y0,options);
function F = myfun(~,y)
global G0
mu0 = y(1); mu1 = y(2); mu2 = y(3); mu3 = y(4); mu4 = y(5); mu5 = y(6);
w1 = y(7); w2 = y(8); w3 = y(9); l1 = y(10); l2 = y(11); l3 = y(12);
F = zeros(12,1);
%Differential Equations
F(1) = 0;
F(2) = G0*(w1/l1 + w2/l2 + w3/l3);
F(3) = 2*G0*(w1 + w2 + w3);
F(4) = 3*G0*(l1*w1 + l2*w2 + l3*w3);
F(5) = 4*G0*(w1*l1^2 + w2*l2^2 + w3*l3^2);
F(6) = 5*G0*(w1*l1^3 + w2*l2^3 + w3*l3^3);
%Algebraic equations
F(7) = w1 + w2 + w3 - mu0;
F(8) = l1*w1 + l2*w2 + l3*w3 - mu1;
F(9) = w1*l1^2 + w2*l2^2 + w3*l3^2 - mu2;
F(10) = w1*l1^3 + w2*l2^3 + w3*l3^3 - mu3;
F(11) = w1*l1^4 + w2*l2^4 + w3*l3^4 - mu4;
F(12) = w1*l1^5 + w2*l2^5 + w3*l3^5 - mu5;
end
๋๊ธ ์: 0
๋ต๋ณ (1๊ฐ)
Torsten
2022๋
2์ 27์ผ
for i = 0:5
mu0(i+1) = w10*L10^i + w20*L20^i + w30*L30^i;
end
instead of
for i = 1:6
mu0(i) = w10*L10^i + w20*L20^i + w30*L30^i;
end
๋๊ธ ์: 3
Torsten
2022๋
2์ 27์ผ
By the way your suggestion is not valid in my problem because,
Mu0(1) = W1 + W2 + W3,
IF I change according to your response it will be different
Mu0(1) = W1*L1 + W2*L2 + W3*L3
Wrong. You get
Mu0(1) = W1*L1 + W2*L2 + W3*L3
if you don't make the change according to my suggestion.
And for me, your code is working fine after the correction.
์ฐธ๊ณ ํญ๋ชฉ
์นดํ ๊ณ ๋ฆฌ
Help Center ๋ฐ File Exchange์์ Ordinary Differential Equations์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!