フィルターのクリア

Solving a Differential equation plus plotting results: Fluid Mechanics

4 ビュー (過去 30 日間)
Kyle
Kyle 2013 年 4 月 12 日
I am trying to create a code to: 1) Solve this differential Equation for h(t) (or h2) in terms of t. 2) Solve for t at a certain h2. 3) Plot h2 versus t
the equation is (dh/dt)=(-36290.323)*[(((2*mw*g*t)/(Gama*Atank))+(2*g*h))^(1/2)]
Thank you for your help.

回答 (1 件)

Youssef  Khmou
Youssef Khmou 2013 年 4 月 12 日
hi Kyle,
You can try as the following :
1) Create a function in M-file inwhich you define the equation :
function dh=MYFunc(t,h)
%(dh/dt)=(-36290.323)*[(((2*mw*g*t)/(Gama*Atank))+(2*g*h))^(1/2)]
A=-36290.323;
mw=2.33;
g=9.81;
Gamma=1.23;
Atank=4;
dh(1)=A*(((2*mw*g*t)/(Gamma*Atank))+(2*g*h(1))).^(1/2);
2) In the workspace you call the function "ode23" or "ode45" as :
t0=0; % staring time
tf=10; % t final
Initial_value=2; % the initial value for h
[t,h]=ode45('MYFunc',t0,tf,[Initial_value]);
figure, plot(t,abs(h));
Adjust the parameters, and try ...because in this case h is complex .
  2 件のコメント
Kyle
Kyle 2013 年 4 月 12 日
Thank you for your help Youssef.
Code is working great. One question I have about the code for part 2. I have the final value of h that I am looking for. Is there a way to plug in the initial and final values to get tf?
Youssef  Khmou
Youssef Khmou 2013 年 4 月 12 日
hi Kyle,
no i can not tell, that may be possible if we already know the Sampling frequency of t .

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by