I have to solve this equation in matlab with ode45 when T is in range [0,12]:
I want that when:
- T > Tend, switch is 0,
- (T < Tin and dT/dt > 0), switch is 1.
I see the documentation here but I can't understand how do it.
clc;
clear all;
close all;
global Q Tamb n swicth
Tamb = 0;
Q = 1000;
n = 1/3;
Ti = 0;
swicth = 1;
T_end = 2000;
maxT = 12;
tspan = [0 maxT];
CI = [Ti];
[TOUT,YOUT] = ode45(@odefun,tspan, CI); <--------- ??
odefun function:
function T = odefun(t, Tin)
global Q Tamb n swicth
T = (swicth*Q - (Tin - Tamb)^n);
end
As I said above, I don't want to pass a parameter to a function! Perhaps the previous title was misleading, but I think my question was clear. However I try to explain better. Ode45 numerical integrate my function, so it gives me the value of a function at time t_i (f(t_i)) and this is repeated for each t_i in [0:12]. I want, based on the value of the function at a time t_i, to change the value of the switch for the integration at time t_(i+1).[The rules is explain above].