How to solve this equation?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
성훈 김
el 23 de Ag. de 2021
Comentada: Star Strider
el 25 de Ag. de 2021
Hey guys
How can I solve this simple ode equation with matlab??
1 comentario
Wan Ji
el 23 de Ag. de 2021
Hi 金成勋 my friend,
This is a first-order nonlinear ode with power exponent other than 1, far more complicated than you ever imagine.
Respuesta aceptada
Star Strider
el 23 de Ag. de 2021
One approach —
syms h(t) t Y
Dh = diff(h);
Eqn = 25*pi*Dh == pi*(4*0.0254)^2 * sqrt(2*9.8*h*2*(101325/876)+Dh^2)+90/3600
Eqn = isolate(Eqn,Dh)
[VF,Subs] = odeToVectorField(Eqn)
VF = simplify(VF, 500)
hfcn = matlabFunction(VF, 'Vars',{t,Y})
Then use the appropriate numerical ODE solver (most likely ode15s) to integrate it.
.
5 comentarios
Star Strider
el 25 de Ag. de 2021
The equation itself does not have any parameters that can be estimated that would give a negative slope.
The sqrt term has both positive and negative roots, so change the sign of that term to get the negative square roots:
hfcnp = @(t,Y)[(pi.*8.112963841460668e+32+sqrt(7.3e+1).*sqrt(Y(1).*-1.129628243491514e+37+pi.^2.*Y(1).*6.713376166760685e+42+1.480615901066572e+33).*3.201062735323997e+12)./(pi.^2.*8.112963841460668e+35-1.365130281111817e+30)];
hfcnn = @(t,Y)[(pi.*8.112963841460668e+32-sqrt(7.3e+1).*sqrt(Y(1).*-1.129628243491514e+37+pi.^2.*Y(1).*6.713376166760685e+42+1.480615901066572e+33).*3.201062735323997e+12)./(pi.^2.*8.112963841460668e+35-1.365130281111817e+30)];
% ↑ ← HERE
tspan = [0 10];
ic = 0;
[tp,yp] = ode15s(hfcnp, tspan, ic);
[tn,yn] = ode15s(hfcnn, tspan, ic);
figure
yyaxis left
plot(tp, yp)
ylabel('h(t) +Root')
yyaxis right
plot(tn, yn)
grid
xlabel('t')
ylabel('h(t) -Root')
legend('Positive Root','Negative Root', 'Location','SE')
I doubt that it has a negative slope anywhere.
The only way to force that would be to negate the derivative:
% hfcnp = @(t,Y)-[(pi.*8.112963841460668e+32+sqrt(7.3e+1).*sqrt(Y(1).*-1.129628243491514e+37+pi.^2.*Y(1).*6.713376166760685e+42+1.480615901066572e+33).*3.201062735323997e+12)./(pi.^2.*8.112963841460668e+35-1.365130281111817e+30)];
% hfcnn = @(t,Y)-[(pi.*8.112963841460668e+32-sqrt(7.3e+1).*sqrt(Y(1).*-1.129628243491514e+37+pi.^2.*Y(1).*6.713376166760685e+42+1.480615901066572e+33).*3.201062735323997e+12)./(pi.^2.*8.112963841460668e+35-1.365130281111817e+30)];
% % ↑ ← HERE
%
% tspan = [0 10];
% ic = 0;
% [tp,yp] = ode15s(hfcnp, tspan, ic);
% [tn,yn] = ode15s(hfcnn, tspan, ic);
%
% figure
% yyaxis left
% plot(tp, yp)
% ylabel('h(t) +Root')
% yyaxis right
% plot(tn, yn)
% grid
% xlabel('t')
% ylabel('h(t) -Root')
% legend('Positive Root','Negative Root', 'Location','SE')
I cannot run that (the commented-out code) here because it times out, and even takes an extraordinarily long time on my computer when I run it offlline, so it may not have s solution.
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!