0

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.

M-file:

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 it is giving an error. Please explain how to use the inputs with changing time with this example.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • 2
    What error message do you get? – Daniel Jan 18 '16 at 10:47
  • This one: Error using odearguments (line 90) @(T,TS)TEMP(T,TS,QU) must return a column vector. Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin); – user3897269 Jan 18 '16 at 11:02
  • See http://www.mathworks.com/matlabcentral/answers/97074-how-do-i-solve-an-ode-with-time-dependent-parameters-in-matlab. Google also returns loads of hits on the same topic, quite a few on SO as well. – am304 Jan 18 '16 at 11:33

0 Answers0