How to solve this equation?

1 次查看(过去 30 天)
Hey guys
How can I solve this simple ode equation with matlab??
  1 个评论
Wan Ji
Wan Ji 2021-8-23
Hi 金成勋 my friend,
This is a first-order nonlinear ode with power exponent other than 1, far more complicated than you ever imagine.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2021-8-23
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 个评论
성훈 김
성훈 김 2021-8-25
编辑:성훈 김 2021-8-25
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 2021-8-25
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.
.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by