-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpmodx.m
More file actions
65 lines (54 loc) · 2.09 KB
/
Copy pathpmodx.m
File metadata and controls
65 lines (54 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function [X,CC,vx,vy] = pmodx(X,TT,K,n,vx,vy)
%PMODX Periodic LPV system identification using the PBSIDopt method.
% [X,CC] = pmodx(X,UM,K,n) estimates the state sequence X of the
% identifiable system with order n. The order n can be determined from the
% correlation coefficients C given by dordopt. The matrices UM and K are
% also calculated by pordvarx.
%
% [X,CC] = pmodx(X,UM,K,n,vx,vy) specifies the regularized parameters vx
% and vy for the regularized canonical correlation analysis solver. For vx
% > 0 and vy > 0, the solver can better deal with ill-conditioned
% covariance matrices. To use the k-fold cross validation to calculate the
% regularized parameter with best score, choose the vector vx as for
% example vx = logspace(-8,-2). For vectors with lengths larger the two,
% the code automatically uses cross validation. (default vx=0 and vy=0)
%
% [X,CC,vxm,vym] = pmodx(X,UM,K,n,vx,vy) also returns the best regularized
% parameter found by the k-fold cross validation.
%
% References:
% [1] van Wingerden, J.W., Houtzager, I., Verhaegen, M., Closed-loop
% identification of the time-varying dynamics of variable-speed wind
% turbines, Int. J. Robust Nonlinear Control 2008
%
% See also: pordxarx, px2abcdk, and px2abck.m.
% Ivo Houtzager
% Delft Center of Systems and Control
% Delft University of Technology
% The Netherlands, 2010
% check number of arguments
if nargin < 3
error('PMODX requires at least three input arguments.');
end
% cheack the dimensions of the inputs
if (n < 1) || isempty(n)
error('System order of zero or lower does not make sense!')
end
% allocate matrices
j = size(X,1);
fl = size(TT{1},1);
UM = zeros(j*fl,j*n);
for q = 1:j
UM((q-1)*fl+1:q*fl,(q-1)*n+1:q*n) = TT{q,1}(:,1:n);
end
clear TT;
% solve intersection problem
if (length(vx) > 1) || (length(vy) > 1)
[vx,vy] = kfcv(UM,K,q,vx,vy);
end
[CC,TU] = rcca(UM,K,vx,vy);
% obtain the state sequence using the transformation matrix
TU = TU(1:j*n,1:n);
for q = 1:j
X{q,1} = TU((q-1)*n+1:n*q,:)\X{q,1}(1:n,:);
end