MATLAB Answers

PEM grey box using merged data.

2 views (last 30 days)
Mike
Mike on 27 Aug 2012
I am trying to understand exactly the underlying theory that pem uses working with merged data. Specifically, I am using a grey box model where the initial conditions and Kalman gain is parameterized by me. Is it just performing the identification separately and then combining the result or is it estimated in one run with two sets of initial conditions. Code is included as an example.
%%Define system
A = [0.8 0.1; 0.1 0.7];
B = [0.2; 0.7];
C = [1 0];
D = 0;
Q = 0.1;
R = 0.1;
Ts = 1;
%%Simulate the system twice
n = 200;
y = cell(2, 1);
y{1} = zeros(1, n);
y{2} = y{1};
u = [0*ones(1, 20), 1*ones(1, 30), 2*ones(1, 20), -1*ones(1, 20), 0*ones(1, 30), 2*ones(1, 20), 0*ones(1, 30), -2*ones(1, 30)];
x = zeros(2, n + 1);
for i = 1:2;
if( i == 1 )
x(:, 1) = [4; 4];
else
x(:, 1) = [-1; -1];
end
for k = 1:n;
y{i}(k) = C*x(:, k) + D*u(:, k) + sqrt(R)*randn;
x(:, k + 1) = A*x(:, k) + B*u(:, k) + sqrt(Q)*randn;
end
end
%%plot output
plot([y{1}', y{2}']);
%%gather data
data1 = iddata(y{1}', u', Ts);
data2 = iddata(y{2}', u', Ts);
data_all = merge(data1, data2);
%%identify
model1 = idgrey('sysmodel', zeros(1, 6), 'd');
options = greyestOptions('Display', 'On', 'Focus', 'Prediction');
options.SearchOption.MaxIter = 1000;
model_out = pem(data_all, model1, options);%, 'OutputWeight', [1 0; 0 0]);
MODEL FUNCTION
function [A, B, C, D, K, X0] = sysmodel(phi, Ts, extra)
%SYSMODEL Summary of this function goes here
% Detailed explanation goes here
A = [phi(1) 0.1; 0.1 phi(2)];
B = [0.2; 0.7];
C = [1 0];
D = 0;
K = [phi(3); phi(4)];
X0 = [phi(5); phi(6)];
end
Bump.
  2 Comments
Mike
Mike on 27 Aug 2012
Yes, I was using pem to specifically mean the function in MATLAB which uses the prediction error method to perform system identification.

Sign in to comment.

Accepted Answer

Rajiv Singh
Rajiv Singh on 7 Sep 2012
Edited: Rajiv Singh on 7 Sep 2012
It is the latter - one combined estimation using both sets of data. If you parametrize initial states x0 (like you do in your sysmdoel file), then you are forcing a joint estimation of initial conditions that somehow do justice to both datasets (in an average sense). To avoid this, you can set the estimation option "InitialState" to "estimate" (options.InitialState = 'estimate'). This causes the X0 returned by sysmodel to be ignored and initial states are estimated separately for each data experiment. The estimated values are stored in model_out.Report.Parameters.X0 (and can also be returned as the second output argument of GREYEST).

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by