Rev 588 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
function y=VibTestAnalyze
(file, colStart, colEnd, debug
)
% Read logfile
log=csvread
(file
);
fs=
11111;
% Sample freq
for col=colStart:colEnd
% Take one of the measurements
inSignal=
log(:,col
)';
inSignal = inSignal -
mean(inSignal
);
n=
length(inSignal
);
if debug
plot(inSignal
);
title('Input SIgnal');
pause
end
% Take FFT
FFT =
fft(inSignal
);
%spec = FFT.*conj(FFT)/n
spec =
2*
abs(FFT);
f = fs/n*
(0:n/
2);
% Freq
if debug
plot(f
(1:
int32(n/
10)),spec
(1:
int32(n/
10)));
title('Spectrum');
xlabel('Hz');
pause
end
if debug
plot(spec
(1:
int32(n/
10)));
title('Spectrum');
pause
end
% Split into components
from =
6;
to =
30;
FFT_ =
FFT;
for k=from:n-from
FFT_
(k
)=
0;
end
lfSignal =
ifft(FFT_,
'symmetric');
FFT_ =
FFT;
for k=
1:from
FFT_
(k
)=
0;
end
for k=to:n-to
FFT_
(k
)=
0;
end
for k=n-from:n
FFT_
(k
)=
0;
end
outSignal =
ifft(FFT_,
'symmetric');
outSignal = outSignal -
mean(outSignal
);
%gr(1,:) = inSignal
gr
(1,:
) = lfSignal;
gr
(2,:
) = outSignal;
% gr(4,:) = lfSignal+outSignal
if debug
plot((1:n
), gr
)
legend('LF',
'Filtered')
pause
end
ppIn =
max(inSignal
)-
min(inSignal
);
ppFiltered =
max(outSignal
)-
min(outSignal
);
rmsFiltered =
sqrt(sum(outSignal.*
conj(outSignal
))/
size(outSignal,
1));
y
(col,
1)=col;
y
(col,
2)=ppIn;
y
(col,
3)=ppFiltered;
y
(col,
4)=rmsFiltered;
end