How to use extra time varying discrete inputs in Ode45?

25 次查看(过去 30 天)
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.

采纳的回答

Torsten
Torsten 2016-1-18
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by