greybox linear model error

1 次查看(过去 30 天)
I get the following error: "The number of inputs and outputs of the model must match that of the data." However, I have ensured the number of outputs are definitely correct - where have I gone wrong?
NB: y= 100x3, u=100x1
load v1v2;
y=[x_store simSoC_TECM];
u=simCurr_TECM;
data = iddata(y,u,1,'Name','Battdata'); %y=O/P (V1,V2), u=I/P (Ibat), Ts=1.
data.OutputName = {'BattV1','BattV2','BattSoc'};
data.OutputUnit = {'V','V','%'};
data.Tstart = 0;
data.TimeUnit = 's';
%%load parameters
load rcbranch
R1=RpTF1mean(5,3);
R2=RpTF2mean(5,3);
T1=TauTF1mean(5,3);
T2=TauTF2mean(5,3);
R0=RoTFmean(5,3);
C1=T1/R1;
C2=T2/R2;
%%construct greybox model
param = {T1;T2;C1;C2;Cnom;R0}
linm = idgrey('batteryeq_lin',param,'c');
function [A,B,C,D] = batteryeq_lin(T1,T2,C1,C2,Cnom,R0,Ts)
A=[-1/T1 0 0;0 -1/T2 0;0 0 0]; %(V1 V2 SOC)
B=[1/C1;1/C2;-1/Cnom];
C=[-1 -1 -1];
D=R0;
%%Specify known and unknown parameters.
for i=1:1:5
linm.Structure.Parameters(i).Free = false;
end
linm.Structure.Parameters(6).Free = true;
linm.Structure.Parameters(6).Minimum = 45e-3;
linm.Structure.Parameters(6).Maximum = 90e-3;
%%Estimate R0.
tic
linm = greyest(data,linm)
toc
Thank you

采纳的回答

Prashant Arora
Prashant Arora 2017-7-17
编辑:Prashant Arora 2017-7-17
Hi Imisi, In your code below
function [A,B,C,D] = batteryeq_lin(T1,T2,C1,C2,Cnom,R0,Ts)
A=[-1/T1 0 0;0 -1/T2 0;0 0 0]; %(V1 V2 SOC)
B=[1/C1;1/C2;-1/Cnom];
C=[-1 -1 -1];
D=R0;
C is defined as a row vector, which implies that the state-space model has only 1 output, as opposed to 3 outputs created with iddata. This is causing a mismatch and results in an error. Essentially C*x + D returns a scalar according to the equations you have specified.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by