a b/Body/Beta/AAUCow/FiltKinematic.asv
1
data = Humerus3;
2
3
x = data(:,2);
4
y = data(:,3);
5
z = data(:,4);
6
N = length(x);          
7
n = 0:N-1; 
8
9
top = max(data(:,4));
10
bottom = max(data(:,4));
11
12
% Fast Fourier transform
13
S=fft(x);
14
15
figure (1);
16
17
% Signal in Time domain
18
subplot(4,1,1);
19
plot(n,x);
20
axis([0,295,-200,top*1.1]);
21
22
% Signal in frequence domain
23
subplot(4,1,2);
24
plot(n,S);
25
axis([0,295,-inf,inf]);
26
27
% Determination of order and corresponding cutoff frequency
28
% SPECIFICATIONS: DC-gain: 0 dB, Passband: 0<f<33 Hz,
29
% Maximum ripple in the passband: 1 dB, Stopband: f>50 Hz
30
% Stopband attenuation > 40 dB, Sample frequency: 1000 Hz
31
[N, Wn] = BUTTORD(3/120, 12/120, 1, 40);
32
33
% Determination of the filter coefficients 
34
[B,A] = BUTTER(N,Wn);
35
36
% Returns the frequency response vector h and the corresponding 
37
% frequency vector w for the filter with coefficients A, B
38
[Hz,w]=freqz(B,A); 
39
40
% Plot of frequency response
41
subplot(4,1,3);
42
plot(w,abs(Hz));
43
axis([0 1 0 1]);
44
45
% Filter
46
X = filtfilt(B,A,x);
47
Y = filtfilt(B,A,y);
48
Z = filtfilt(B,A,z);
49
50
51
dataFilt(:,1) = Scapula1(:,1);
52
dataFilt(:,2) = X;
53
dataFilt(:,3) = Y;
54
dataFilt(:,4) = Z;
55
56
figure(2)
57
Subplot(2,3,1)
58
plot (data(1:295,2)); figure(gcf)
59
Subplot(2,3,2)
60
plot (data(1:295,3)); figure(gcf)
61
Subplot(2,3,3)
62
plot (data(1:295,4)); figure(gcf)
63
64
Subplot(2,3,4)
65
plot (dataFilt(1:295,2)); figure(gcf)
66
Subplot(2,3,5)
67
plot (dataFilt(1:295,3)); figure(gcf)
68
Subplot(2,3,6)
69
plot (dataFilt(1:295,4)); figure(gcf)
70
71
72
figure(3)
73
subplot(2,2,1)
74
plot(data(1:295,4))
75
subplot(2,2,3)
76
plot(dataFilt(1:295,4))
77
subplot(2,2,2)
78
plot(data(195:220,4))
79
subplot(2,2,4)
80
plot(dataFilt(195:220,4))