-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgenstat.m
108 lines (83 loc) · 2.57 KB
/
genstat.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
function [mag1sig,phs1sig,coh1sig,cps1sig] = genstat(G,Gxy,Coh,navg)
%
% Name: genstat
%
% Usage: [mag1sig,phs1sig,coh1sig,cps1sig] = genstat(G,Gxy,Coh,navg)
%
% Purpose: Generate the statistical (1 sigma) error bounds on the
% spectral estimates from a modal test:
%
% Inputs:
% G = measured FRF estimate
% Gxy = measured CPS estimate
% Coh = measured coherence estimate
% navg = number of experimental averages
%
% Outputs:
% mag1sig = 1 sigma std for FRF magnitude
% phs1sig = 1 sigma std for FRF phase
% coh1sig = 1 sigma std for coherence function
% cps1sig = 1 sigma std for CPS magnitude
%
% Version SWD970730
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% Interpolate points in Coherence where the value is zero
%
[zpveci,zpvecj] = find(Coh == 0);
for i = 1:length(zpveci),
Coh(zpveci(i),zpvecj(i)) = (Coh(zpveci(i)+1,zpvecj(i)) + Coh(zpveci(i)-1,zpvecj(i)))/2;
end
%
% FRF magnitude
%
mag1sig = sqrt(1 - Coh) ./ sqrt(Coh * 2 * navg) .* abs(G);
%
% FRF phase
%
%phs1sig = 0.5 * sqrt(1 - Coh) ./ sqrt(Coh * 2 * navg) .* angle(G);
ephs = sqrt(1 - Coh) ./ sqrt(Coh * 2 * navg);
%
% Make sure argument for asin is always <=1
[gt1i,gt1j] = find(ephs>1);
for i = 1:length(gt1i),
ephs(gt1i(i),gt1j(i))=1;
end
phs1sig = asin(ephs);
%
% Coherence
%
coh1sig = sqrt(2) * (1 - Coh) ./ sqrt(Coh * navg) .* Coh;
%
% Cross-Power Spectrum
%
cps1sig = 1 ./ sqrt(Coh * navg) .* Gxy;
%
% Compute bounds on FRF based on mag and phase bounds
%
%gmag = abs(G);
%gph = angle(G);
%sgph = sin(gph);
%cgph = cos(gph);
%real1sig = sqrt( (cgph .* mag1sig).^2 + (gmag .* sgph .* phs1sig).^2 );
%imag1sig = sqrt( (sgph .* mag1sig).^2 + (gmag .* cgph .* phs1sig).^2 );
return