forked from wozy13/DIAMOND
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emaccomp.m
166 lines (103 loc) · 3.43 KB
/
emaccomp.m
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
function [emac_tot,msv] = emaccomp(A,V,W,q,d,fs)
%
% emaccomp
%
% [emac,msv] = emaccomp(A,V,W,q,d,fs)
%
% Computes extended modal amplitude coherence (emac_tot)
% for system with discrete-time state matrix A, and
% discrete-time observability and controllability matrices
% V and W
%
% q and d are the ERA Hankel matrix block dimensions
%
% fs is the sampling frequency
%
% (Assumes measurements are acceleration)
% Reference: "Consistent-Mode Indicator for the Eigensystem
% Realization Algorithm," Pappa, Elliott, Schenk, J. of
% Guidance, Control, and Dynamics, v. 16, No. 5, 1993.
% Version SWD960207
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally %
% developed as part of "DIAMOND" at %
% Los Alamos National Laboratory. It may %
% be copied, modified, and distributed in %
% any form, provided: %
% a) This notice accompanies the files and %
% appears near the top of all source %
% code files. %
% b) No payment or commercial services are %
% received in exchange for the code. %
% %
% Original copyright is reserved by the %
% Regents of the University of California, %
% in addition to Scott W. Doebling, Phillip %
% J. Cornwell, Erik G. Straser, and Charles %
% R. Farrar. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
nx = size(A,1);
nresp = size(V,1) / q;
nref = size(W,2) / d;
emac_tot_num = zeros(nx,1);
emac_tot_den = zeros(nx,1);
msv = zeros(nx,1);
% Put model in discrete-time modal form
[vd,dd] = eig(A);
Vmo = V * vd / dd^2;
Wmo = inv(vd) * W;
% Find continuous-time eigenvalues
s = log(diag(dd)) * fs;
% Compute EMAC for each state
for i = 1:nx,
% Do over every input-output pair
for k = 1:nref,
%
% Compute input EMAC for this state
%
Wmo_sim = Wmo(i,k) * exp(s(i) * (d-1) / fs);
Wmo_final = Wmo(i, (d-1)* nref + k);
if abs(Wmo_sim) >= abs(Wmo_final),
Rik = abs(Wmo_final)/abs(Wmo_sim);
else
Rik = abs(Wmo_sim)/abs(Wmo_final);
end
Pik = abs(angle(Wmo_final / Wmo_sim));
if Pik <= pi/4,
Wik = 1 - Pik * 4/pi;
else
Wik = 0;
end
emac_in = Rik * Wik;
for j = 1:nresp,
%
% Compute output EMAC for this state
%
Vmo_sim = Vmo(j,i) * exp(s(i) * (q-1) / fs);
Vmo_final = Vmo((q-1)* nresp + j , i);
if abs(Vmo_sim) >= abs(Vmo_final),
Rij = abs(Vmo_final)/abs(Vmo_sim);
else
Rij = abs(Vmo_sim)/abs(Vmo_final);
end
Pij = abs(angle(Vmo_final / Vmo_sim));
if Pij <= pi/4,
Wij = 1 - Pij * 4/pi;
else
Wij = 0;
end
emac_out = Rij * Wij;
emac_tot_num(i) = emac_tot_num(i) + emac_out * emac_in * abs(Vmo(j,i))^2 * abs(Wmo(i,k))^2;
emac_tot_den(i) = emac_tot_den(i) + abs(Vmo(j,i))^2 * abs(Wmo(i,k))^2;
end
end
% Compute msv for this state
if i < nx
msv(i) = norm(Vmo(:,i:i+1),'fro') + norm(Wmo(i,i:i+1),'fro');
end
end
emac_tot = emac_tot_num ./ emac_tot_den;
msv = msv / max(msv);
return