Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
588 fredericg 1
 
2
function y=VibTestAnalyze(file, colStart, colEnd, debug)
3
 
4
% Read logfile
5
log=csvread(file);
6
fs=11111; % Sample freq
7
 
8
 
9
for col=colStart:colEnd
10
    % Take one of the measurements
11
    inSignal=log(:,col)';
12
    inSignal = inSignal - mean(inSignal);
13
    n=length(inSignal);
14
 
15
    if debug
16
        plot(inSignal);
17
        title('Input SIgnal');
18
        pause
19
    end
20
 
21
    % Take FFT
22
    FFT = fft(inSignal);
23
    %spec = FFT.*conj(FFT)/n
24
    spec = 2*abs(FFT);
25
 
26
    f = fs/n*(0:n/2); % Freq
27
 
28
    if debug
29
        plot(f(1:int32(n/10)),spec(1:int32(n/10)));
30
        title('Spectrum');
31
        xlabel('Hz');
32
        pause
33
    end
34
 
35
    if debug
36
        plot(spec(1:int32(n/10)));
37
        title('Spectrum');
38
        pause
39
    end
40
 
41
    % Split into components
42
    from = 6;
43
    to = 30;
44
 
45
    FFT_ = FFT;
46
    for k=from:n-from
47
        FFT_(k)=0;
48
    end
49
    lfSignal = ifft(FFT_, 'symmetric');
50
 
51
    FFT_ = FFT;
52
    for k=1:from
53
        FFT_(k)=0;
54
    end
55
    for k=to:n-to
56
        FFT_(k)=0;
57
    end
58
    for k=n-from:n
59
        FFT_(k)=0;
60
    end
61
    outSignal = ifft(FFT_, 'symmetric');
62
    outSignal = outSignal - mean(outSignal);
63
 
64
    %gr(1,:) = inSignal
65
    gr(1,:) = lfSignal;
66
    gr(2,:) = outSignal;
67
    % gr(4,:) = lfSignal+outSignal
68
 
69
    if debug
70
        plot((1:n), gr)
71
        legend('LF','Filtered')
72
        pause
73
    end
74
 
75
    ppIn = max(inSignal)-min(inSignal);
76
    ppFiltered = max(outSignal)-min(outSignal);
77
    rmsFiltered = sqrt(sum(outSignal.*conj(outSignal))/size(outSignal,1));
78
 
79
 
80
    y(col,1)=col;
81
    y(col,2)=ppIn;
82
    y(col,3)=ppFiltered;
83
    y(col,4)=rmsFiltered;
84
end
85
 
86