-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyseint.m
55 lines (49 loc) · 1.48 KB
/
analyseint.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
% Camila Rosa (crs94 @GitHub), 2018
% ------------
% analyseint: Analyse the FFT of each rep of the signal
% Usage: Input the name of the variable in which
% the signal is stored cut it by the intervals
% that were previouly determined and calculate
% the magnitude spectra, MDS and max amplitude
% Inputs:
% data = [var] Variable in which the signal
% is stored
% fs = [double] Sampling frequency
% inter = [matrix] Matrix containing the
% intervals of each serie of rep
% Output: none
% ------------
function [segment] = analyseint(data, fs)
close all;
%Creating inital data
N = length(data); % Number of samples
wsize = 256; % Size of window that selects data
segment = {};
pwrspec = calc_power(data, wsize); % Calculating power of data
pwrspec = pwrspec/max(pwrspec); % Normalizing values
threshold = mean(pwrspec); % Defining threshold
plot(pwrspec, 'bo'); hold on;
plot([0 (N/wsize)-1], [threshold threshold], 'r--');
hold off;
k = 1;
n = 1;
figure;
hold on;
while n > length(pwrspec)
if pwrspec(n) >= threshold
m = n;
while pwrspec(m) > threshold
m = m + 1;
end
segment{k} = data(n*wsize:m*wsize);
plot(n:1/wsize:m, segment{k});
k = k + 1;
n = m;
pause;
end
end
%figure;
%plot(segment);
%hold on;
%plot([0 N/wsize], [threshold threshold], 'r--');
%hold off;