ODE45: ODE Error using odearguments must return a column vector

2 次查看(过去 30 天)
I have the following equation and I want to solve this equation for 10525 timestep (for a day) to get the "Tm" values. However, I am getting error.
This is actually a simple energy balance:
Qstore = Qinj - Qemitted
Hence;
dTm/dt = 1/C_rad * ((Qinj)- (C*(Tm-Tair).^n))
In the above equation all other parameters are constant except ''Qinj''. Qinj is actually the heat injected to the radiator and it has a step change. I am using ODE45 to solve this. The purpose is to observe the change in Tm by changing the Qinj.
So I want to solve the above equation for 10525 different timesteps to get the Tm for each data point. Since this is the continuous data so the initial value for Tm (Tm0) for the next timestep will be equal to the Tm value for the previous timestep (Becuase this is the time-series data).
I have following code. Can anyone please help me to fix this problem? Thanks in advance!
%% Auusmptions &constant parameters
n = 1.3581 ; % Capacity exponent for the unit
Tsu = 75; % [C] inlet temperature of the radiator
Tair = 21; % [C] Air temperature
C_rad = 5.7770e+04; % Total thermal capacity of radiator
C=10;
%% Time series data for Qinj_t
tQinj= (0:0.0022805:24)'; %Because I have data for 24 hourse with 0.0022805 timestep
step = 10524; %
tspan =[0 0.0022805];
t0 = 0; % Start time
t1 = 24; % Final time
t = linspace(t0 , t1 , (step+1));
%% Reading data from Excel sheet
[num txt raw] = xlsread('Radiator_sweep190.xlsx');
Qinj_t = num(:,4); (10525X1)
Qinj_td = interp1(tQinj, Qinj_t, t, 'linear');
%% ODE expression
Tmo = 20 ; % Initial condition
[t,Tm] = ode45(@(t,Tm) rad_h(t, Tm, tQin, C_rad, Qinj_td, C, Tair, n ),tspan,Tmo);
%% Following function is used:
function dtmdt = rad_h(t, Tm, tQin, C_rad, Qinj_td, C, Tair, n )
dtmdt = 1/C_rad*((Qinj_td)- (C*(Tm-Tair).^n))
end

回答(1 个)

Stephan
Stephan 2019-4-25
dtmdt = (1/C_rad*((Qinj_td)- (C*(Tm-Tair).^n)))'
  2 个评论
Haseeb
Haseeb 2019-4-25
Hi Stephan, thanks for your response. However, I am still getting the same Error. Error is not in the function but it's in ODE45 expression.
It says:
Error using odearguments (line 93)
@(T,TM)RAD_H(T,TM,TQINJ,C_RAD,QINJ_TD,C,TAIR,N)
must return a column vector.
Stephan
Stephan 2019-4-25
编辑:Stephan 2019-4-25
what is it returning? what is the result of:
%% Following function is used:
function dtmdt = rad_h(t, Tm, tQin, C_rad, Qinj_td, C, Tair, n )
dtmdt = (1/C_rad*((Qinj_td)- (C*(Tm-Tair).^n)))';
size(dtmdt)
end
Running this will tell us which size dtmdt is before the error is thrown. Then we can see more. Please also attach your data file.

请先登录,再进行评论。

类别

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