-
Notifications
You must be signed in to change notification settings - Fork 1
/
NExT.m
78 lines (73 loc) · 2.12 KB
/
NExT.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
function [R,t] = NExT(y,dt,Ts,method)
%
% [R] = NExT(y,ys,T,dt) implements the Natural Excitation Technique to
% retrieve the free-decay response (R) from the cross-correlation
% of the measured output y.
%
%
% Synthax
%
% [R] = NExT(y,dt,Ts,1) calculates R with cross-correlation
% calculated by using the inverse fast fourier transform of the
% cross-spectral power densities without zero-padding(method = 1).
%
% [R] = NExT(y,dt,Ts,2) calculate the R with cross-correlation
% calculated by using the unbiased cross-covariance function (method = 2)
%
% Input
% y: time series of ambient vibrations: vector of size [1xN]
% dt : Time step
% method: 1 or 2 for the computation of cross-correlation functions
% T: Duration of subsegments (T<dt*(numel(y)-1))
%
% Output
%
% R: impusle response function
% t: time vector asociated to R
%
% Author: E. Cheynet - UiB - last modified 14-05-2020
%%
if nargin<4, method = 2; end % the fastest method is the default method
if ~ismatrix(y), error('Error: y must be a vector or a matrix'),end
[Nyy,N]=size(y);
if Nyy>N
y=y';
[Nyy,N]=size(y);
end
% get the maximal segment length fixed by T
M = round(Ts/dt);
switch method
case 1
clear R
for ii=1:Nyy
for jj=1:Nyy
y1 = fft(y(ii,:));
y2 = fft(y(jj,:));
h0 = ifft(y1.*conj(y2));
R(ii,jj,:) = h0(1:M);
end
end
% get time vector t associated to the R
t = linspace(0,dt.*(size(R,3)-1),size(R,3));
if Nyy==1
R = squeeze(R)'; % if Nyy=1
end
case 2
R = zeros(Nyy,Nyy,M+1);
for ii=1:Nyy
for jj=1:Nyy
[dummy,lag]=xcov(y(ii,:),y(jj,:),M,'unbiased');
R(ii,jj,:) = dummy(end-round(numel(dummy)/2)+1:end);
end
end
if Nyy==1
R = squeeze(R)'; % if Nyy=1
end
% get time vector t associated to the R
t = dt.*lag(end-round(numel(lag)/2)+1:end);
end
% normalize the R
if Nyy==1
R = R./R(1);
else
end