vectors input to ODE 45

조회 수: 1 (최근 30일)
Oday Shahadh
Oday Shahadh 2017년 2월 23일
답변: Walter Roberson 2017년 2월 23일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 23일
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)

카테고리

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