How can i solve initial value ordinary differential equation using matlab ??
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Surendra Ratnu
le 21 Août 2023
Commenté : Surendra Ratnu
le 21 Août 2023
I want to solve four differtial equation and these are shown in picture. Here u,s,p,r are dependent variable and t is the independent variable. W and a are the constant (values are 154 and 44.5 degree). t is the independent variable and varies from 0 to 180 degree. initial condition are u0 = 0.10, so = 0.2025, p0 = 1.4706, r0 = 2.2449.
5 commentaires
Bruno Luong
le 21 Août 2023
Some obvious mixe and match unit : sin and cos take argument in radian not in degree
Réponse acceptée
Bruno Luong
le 21 Août 2023
Modifié(e) : Bruno Luong
le 21 Août 2023
I change integration variables to v=u*s and w=u^2*s;
This should work (you need to sort out the discrepency of unit, speccially for t)
W = 154;
a = deg2rad(44.5);
u0 = 0.10;
s0 = 0.2025;
p0 = 1.4706;
r0 = 2.2449;
v0 = u0*s0;
w0 = u0^2*s0;
y0 = [v0;w0;p0;r0];
sol = ode45(@(t,y) odefun(t,y,a,W),[0 pi],y0);
t = sol.x;
y = sol.y;
v = y(1,:);
w = y(2,:);
p = y(3,:);
r = y(4,:);
u = w./v;
s = v./u;
tdeg = rad2deg(t)
figure
subplot(2,2,1); plot(tdeg, u); xlabel('tdeg'); ylabel('u')
subplot(2,2,2); plot(tdeg, s); xlabel('tdeg'); ylabel('s')
subplot(2,2,3); plot(tdeg, p); xlabel('tdeg'); ylabel('p')
subplot(2,2,4); plot(tdeg, r); xlabel('tdeg'); ylabel('r')
function dydt = odefun(t, y, a, W)
%v = y(1); % u*s
w = y(2); % u^2*s
p = y(3);
r = y(4);
sina = sin(a);
cosacost = cos(a).*cos(t);
c = sina^3./(4*(1+cosacost).^2);
dvdt = c;
dwdt = c.*cos(p);
dpdt = (2*r/W - c*sin(p).^2) ./ (w.*sin(p)) - 1;
drdt = t ./ tan(p);
dydt = [dvdt; dwdt; dpdt; drdt];
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

