Errors occur during grey-box modeling

2 views (last 30 days)
Haoquan
Haoquan on 12 Apr 2013
Currently I am trying to build up a thermal model of a lecture theater using grey-box modeling in system identification toolbox. First I specified the model structure in a function file whose content is shown below:
function [A, B, C, D, K, x0] = thermalmdl_ode(R1, R2, R3, R4, C1, C2, Ts) % This function parameterizes the thermal model of the lecture theatre
% R1 is the convective heat transfer resistance of the outside surface of
% the wall and roof
% R2 is half of the conductive heat transfer resistance of the wall and
% roof
% R3 is the conductive heat transfer resistance of the window
% R4 is the convective heat transfer resistance of the inside surface of
% the wall and roof
% C1 is the heat capacity of the wall and roof
% C2 is the heat capacity of the lecture theatre
% Define some useful variables a=1/R1+1/R2+1/R3; b=1/R2+1/R3+1/R4; c=R3^2*a*b-1;
% A matrix
A=zeros(2,2);
A(1, 1)=(1-b*R4)/(C2*b*R4^2);
A(1, 2)=(1+R3*a)*R3/(C2*R2*R4*c);
A(2, 1)=(c+b)/(b*c*R4*C1);
A(2, 2)=(2*R3+R3^2*(a+b)-2*c)/(R2*C1*c);
% B matrix
B=zeros(2,2);
B(1, 1)=R3/(R1*R4*c);
B(1, 2)=R3/(R4*C2*c);
B(2, 1)=R3*(b*R3-1)/(R1*R2*C1*c);
B(2, 2)=R3*(1+b*R3)/(C1*c);
% C matrix
C=[1 0];
% D matrix
D=zeros(2, 2);
% K matrix
K=[-1/C2; 0];
% Initial state
x0=[298.15; 298.15];
end
The input and state of my model are both a 2*1 matrices, the output is a scalar.
Then I tried to create a grey-box model object with idgrey command, but errors occurred:
thermalmdl=idgrey('thermalmdl_ode', {0.000133; 0.000114; 0.0000212;0.000133; 638645.04; 4456.38}, 'cd', {}, 60)
Error using pmodel.LinearODE/checkOutputArgConsistency (line 214)
The sizes of the matrices returned by the ODE function must be consistent with the input/output size and order of the model. Create a new model if you need to change the sizes.
Error in pmodel.LinearODE/checkDataType (line 195)
M = checkOutputArgConsistency(M, Ts, Nargout);
Error in idgrey (line 376)
Structure = checkDataType(pmodel.LinearODE(Orders, Fcn, FcnType, Par, Extras), Ts);
Anyone has any ideas what is going on here?

Answers (1)

Rajiv Singh
Rajiv Singh on 16 Apr 2013
D matrix is 2-by-2 suggesting that the number of inputs (nu) = number of outputs (ny) = 2. However, C is 1-by-2 implying ny = 1. Also K is 2-by-1 implying ny=1. It seems likely that your C and K equations need to be fixed.
  1 Comment
Haoquan
Haoquan on 16 Apr 2013
Yeah, I have already spotted that mistake. But thanks for your response, Rajiv!

Sign in to comment.

Categories

Find more on Linear Model Identification in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!