www.gusucode.com > ident 案例代码 matlab源码程序 > ident/TranslateParameterCovarianceDuringModelConcatenationExample.m

    %% Translate Parameter Covariance During Model Concatenation  
% Concatenate 3 single-output models such that the covariance data from
% the 3 models combine to produce the covariance data for the resulting model.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Construct a state-space model. 
a = [-1.1008 0.3733;0.3733 -0.9561];
b = [0.7254 0.7147;-0.0631 -0.2050];
c = [-0.1241 0; 1.4897 0.6715; 1.4090 -1.2075];
d = [0 1.0347; 1.6302 0; 0.4889 0];
sys = idss(a,b,c,d,'Ts',0);  

%% 
% Generate multi-output estimation data. 
t = (0:0.01:0.99)';
u = randn(100,2);
y = lsim(sys,u,t,'zoh');
y = y +  rand(size(y))/10;
data = iddata(y,u,0.01);  

%% 
% Estimate a separate model for each output signal. 
m1 = ssest(data(:,1,:),2,'feedthrough',true(1,2), 'DisturbanceModel', 'none');
m2 = ssest(data(:,2,:),2,'feedthrough',true(1,2), 'DisturbanceModel', 'none');
m3 = ssest(data(:,3,:),2,'feedthrough',true(1,2), 'DisturbanceModel', 'none');  

%% 
% Combine the estimated models while also translating the covariance information. 
f = @(x,y,z)[x;y;z];
M2 = translatecov(f, m1, m2, m3);  

%% 
% The parameter covariance is not empty. 
getcov(M2, 'factors')  

%% 
% If you combine the estimated models into one 3-output model directly,
% the covariance information is lost (the output of |getcov| is empty). 
M1 = [m1;m2;m3];
getcov(M1)   

%% 
% Compare the confidence bounds. 
h = bodeplot(M2, m1, m2, m3);
showConfidence(h); 

%%
% The confidence bounds for |M2| overlap with those of |m1|, |m2| and |m3|
% models on their respective plot axes.