vectors input to ODE 45

3 views (last 30 days)
Oday Shahadh on 23 Feb 2017
Answered: Walter Roberson on 23 Feb 2017
I have a transient equation below
dT/dt=Qs+Qa+Qir- seg*T
where:
Qs=sun power (watt/m2) % length( 6000,1)
Qa=Earth albedo power (watt/m2) % length( 6000,1)
Qir=Earth radiation power (watt/m2) % length( 6000,1)
Qs , Qa and Qir, already estimated and take the length of( 6000,1) for each power vector
Te0= 300 k (initial temperature)
options=odeset('AbsTol',10^-12,'RelTol',10^-9);
[t,data]=ode45('F1T',tspan,DataIn,options);
function F1T=F1T(t,data)
%TEMPERATURE INTEGRATION
Tdot=((QsunF1+QaF1+QirF1)- T^4
F1T=[Tdot];
end
and I got this error
Error using odearguments (line 92)
F1T returns a vector of length 0, but the length of initial conditions vector is 1. The vector returned by F1T and the initial conditions
vector must have the same number of elements.

Walter Roberson on 23 Feb 2017
You have
function F1T=F1T(t,data)
You need to use a different name for the function and the variable, or MATLAB is going to get confused (and the programmers reading the code are going to get even more confused.)
You have
function F1T=F1T(t,data)
%TEMPERATURE INTEGRATION
Tdot=((QsunF1+QaF1+QirF1)- T^4
F1T=[Tdot];
end
But none of QsunF1, QaF1, QirF1, or T are defined or accessible within the scope of the function. Notice you are passing in t (lower-case) but using T (upper-case)