Help! Trouble understanding differential equation.

조회 수: 3 (최근 30일)
Hidde Kemperink
Hidde Kemperink 2019년 10월 24일
댓글: Hidde Kemperink 2019년 10월 24일
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
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일
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
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개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by