How to numerically solve first order differential equation with dependent variables?

My equation looks like this:
(a1*b1*c1+a2*b2*c2)dT/dt = u*p*V(t) - (k1+k2)*(T-Tinf)
with an initial condition: T(0)=Tinf and V(t)=V0(1-t/ts)
I'm very new to matlab and have been trying to implement dsolve and ode45, but can't figure out how to include the initial condition and the velocity function within the solution. Any help is appreciated.

2 Comments

Please post the code you have tried so far and we can point you in the right direction.
I tried this to start with, just to see what would happen and predictably I received many errors.
function Vel=fvel(t)
Vel=V0(1-t/ts);
function Tdot=ftemp(t,T)
Tdot=(u*p*vel(t)-(k1+k2)(T-25))/(a1*b1*c1+a2*b2*c2); %Tinf=25
>> t0=0; tf=ts; T0=25;
>> [t,T]=ode45('ftemp',[t0 tf],T0);

Sign in to comment.

Answers (1)

You didn't declared variables inside each function
Do this like this
function Vel=fvel(t)
V0 = 5;
ts = 0.3;
Vel = V0*(1-t/ts);

Asked:

on 25 Apr 2020

Answered:

on 25 Apr 2020

Community Treasure Hunt

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

Start Hunting!