Help! Trouble understanding differential equation.

Hi my name is Hidde and i am a first year IEM student,
I got an assignment where i have to solve a differential equation written in the form: f'(t) = A*(g(t) - f(t)) + B*(h(t) - f(t))
I have never seen a DE with multiple functions inside it. I have data for the g(t) where all the values for g(t) are given in the interval [1, 1440] (with steps of 1).
h(t) is discribed as: h'(t) = C*(f(t) - h(t)) + C*(g(t) - h(t)).
i have to use ode45 to solve this problem.

5 件のコメント

Star Strider
Star Strider 2019 年 10 月 24 日
See the documentation on Function Basics if you have not already encountered functions, and the documentation on Anonymous Functions. Then review the documentation on ode45 or whatever solver you believe is necessary. Code the problem you want to solve. If you have problems, post back here. We can help you get your code running.
Hidde Kemperink
Hidde Kemperink 2019 年 10 月 24 日
Hi Star Strider, thanks for your comment!
i've uploaded the template files we got to helpe solve the problem. Our excercice was to edit these templates to solve our problem. I have also uploaded my attempt at this (filesnames with ''1'' added). I understand how the template works but i dont really understand the differential equations given. I am not looking for plagiarism but i am really stuck and my fellow students dont have an answer either. The Tamb is given as a .dat file which i also attached insize a zip file, the excercise pdf is also inside this zip file.
Hidde Kemperink
Hidde Kemperink 2019 年 10 月 24 日
編集済み: Hidde Kemperink 2019 年 10 月 24 日
I have worked with matlab for the past few weeks so i know the basics. I also studied differential equations in Calculus class. I just never encountered a differential equation like this and i dont know how to handle it. And our assignment states we have to use ode45.
John D'Errico
John D'Errico 2019 年 10 月 24 日
You have never seen a differential equation with multiple functions in it? Surely not true. For example, something as simple as this:
y' = x + x^2
or
y' = exp(x) + x
would fit that goal.
Hidde Kemperink
Hidde Kemperink 2019 年 10 月 24 日
my DE's are written as,
dTwalldt = ((Tamb - Twall)/(Cwall * R2) + (Tint - Twall)/(Cwall * R1))
dTintdt = ((Twall - Tint)/(Cint * R1) + (Tamb - Tint)/(Cint * Rwin))
Where Tamb is time dependant.
But matlab keeps saying that it does not recognize Twall. I tried the ode45 with different DE's and they all work but just not this one. I have given values for all constants. What i mean by DE's with multiple functions is that dTwallDt cointains both Twall and Tint.

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

 採用された回答

Cyrus Tirband
Cyrus Tirband 2019 年 10 月 24 日
編集済み: Cyrus Tirband 2019 年 10 月 24 日

0 投票

Your differential equation is time-dependent, with given g(t). Ode45 works iteratively, and calls the function more than once with different values of t. You have to therefore interpolate your g(t) to the given times.
Further, notice that your differential equations can be written as
, where
Knowing this, your ode function then becomes:
function dxdt = odefunc(t,x,g,gt,A,B,C)
f = x(1,:);
h = x(2,:);
g = interp1(gt,g,t); % Interpolate the data set (gt,g) at time t
dxdt(1,:) = B*h+A*g-(B+A)*f;
dxdt(2,:) = C*f+C*g-2*C*h;
end
Which can be directly fed to ode45 with the appropriate function handle, time span, and initial conditions.

5 件のコメント

Hidde Kemperink
Hidde Kemperink 2019 年 10 月 24 日
Thanks for your comment!
Sorry my initial discription of the problem was not quite accurate, i attached a pdf in the Team_82.zip wich discribes the DE's properly at page 2 under "3 Mathematical Model"
Cyrus Tirband
Cyrus Tirband 2019 年 10 月 24 日
I don't see how it is different. You are given T_amb, your time-dependent parameter, and you have a bunch of constants pertaining T_int and T_wall. The implementation is the exact same. You are also given the time frame and the initial conditions, so ode45 can umabiguously solve the set of equations.
Hidde Kemperink
Hidde Kemperink 2019 年 10 月 24 日
Hi Cyrustd thanks for your help!
I've read your code but i have trouble understanding, could you please write the ode function with the given DE's and constants from the pdf file?
Cyrus Tirband
Cyrus Tirband 2019 年 10 月 24 日
It is almost the exact same. Just change the constants so that they correspond to to the constants of your problem. Completing this assignment should come with at the very least this rudimentary understanding.
Then, call the ode45 using the function you made and the appropriate other parameters. Check out the mathworks page on ode45 to acquaint yourself with its use. You won't need anything more than what's on that page.
Good luck with your assignment.
Hidde Kemperink
Hidde Kemperink 2019 年 10 月 24 日
I'll try that, thank you so much for your help!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by