How to solve this equation?

1 view (last 30 days)
성훈 김
성훈 김 on 23 Aug 2021
Commented: Star Strider on 25 Aug 2021
Hey guys
How can I solve this simple ode equation with matlab??
  1 Comment
Wan Ji
Wan Ji on 23 Aug 2021
Hi 金成勋 my friend,
This is a first-order nonlinear ode with power exponent other than 1, far more complicated than you ever imagine.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 23 Aug 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(t) = 
Eqn = isolate(Eqn,Dh)
Eqn = 
[VF,Subs] = odeToVectorField(Eqn)
VF = 
Subs = 
VF = simplify(VF, 500)
VF = 
hfcn = matlabFunction(VF, 'Vars',{t,Y})
hfcn = function_handle with value:
@(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)]
Then use the appropriate numerical ODE solver (most likely ode15s) to integrate it.
.
  5 Comments
성훈 김
성훈 김 on 25 Aug 2021
Edited: 성훈 김 on 25 Aug 2021
i'm sorry to bother you..ㅠㅠ
I want to find the expression h(t-2) with a negative slope.
Can you help me please?
Star Strider
Star Strider on 25 Aug 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.
.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!