How to use extra time varying discrete inputs in Ode45?

15 views (last 30 days)
For example as shown in the function below: Where Ts is the variable with initial value, while Qu is input but it changes with time having specific values defined in the matrix.
function Ts=temp(t,Ts,Qu) Ts=Qu/(1500*4190)-12*10^6/(1500*4190)-11.1*3600*(Ts-20)/(1500*4190);
I am using in this way: Qu=[0 0 0 0 0 0 0 0 21 41 60 75] for j=1:12 Qu=Qu(t); [t,Ts]=ode45(@(t,Ts)temp(t,Ts,Qu),(1:1:12),45) end
But its giving error... please explain how to use inputs with changing time with this example.

Accepted Answer

Torsten
Torsten on 18 Jan 2016
function main
Qu=[0 0 0 0 0 0 0 0 21 41 60 75];
[t,Ts]=ode45(@(t,Ts)temp(t,Ts,Qu),(1:1:12),45)
function dTdt=temp(t,Ts,Qu)
Qu_actual = interp1(1:1:12,Qu,t);
dTdt = Qu_actual/(1500*4190)-12*10^6/(1500*4190)-11.1*3600*(Ts-20)/(1500*4190);
end
Best wishes
Torsten.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!