-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRetrieve_Vels_Freqs.asv
90 lines (71 loc) · 2.78 KB
/
Retrieve_Vels_Freqs.asv
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
79
80
81
82
83
84
85
86
87
88
89
% This mfile will be used to do the basic analysis
% of the raw data.
clear; clc; close all;
%% Define Constants
Min_Magnitude = 5;
% Only analyze transients that generated a
% changein position of 10 degs.
Min_Duration = 10; % ms
transLengthPadded = 10; % sec
% We will pad and window the transients so that
% they have a total length of 10 seconds
padLength = 5; % sec
% We will zero-pad the transients for five seconds
pctCutoff = 0.99; % cutoff for bandwidth is 99%
run(strcat('C:\Users\Ben\Dropbox\BiteBlock\Data\', ...
'Parkour\Parkour_20120202_G1_def.m'));
load(calibration_file);
correction_amp = amp_fit.^(-1);
% We need to divide by the slope of the
% amplitude fit to convert the raw measurements
% to deg / s.
Min_Length = Min_Duration * sampling_rate / 1000;
% minimum number of indices in a transient to include
%% Convert to deg/s.
[Data_Calib, Position] = CalibrateRawData(Data_Raw, DC_fit, ...
sampling_rate, correction_amp);
%% Find indices where tracing switches direction
[transient_pos, transient_vel, numTransients] = RetrieveTransients(Data_Calib, ...
Position, Min_Magnitude, Min_Length);
%% Do frequency analysis
trans_pos_pwrCutoff = retrievePctPwr(Data_Calib, numTransients, ...
transient_pos, sampling_rate, transLengthPadded, padLength, pctCutoff);
%% Retrieve max velocities
max_vels = retrieveMaxVels(Data_Calib, transient_vel, ...
numTransients);
%% Plot results
run_names{1} = 'Fast';
run_names{2} = 'Medium';
run_names{3} = 'Slow';
names{1} = 'Roll';
names{2} = 'Pitch';
names{3} = 'Yaw';
for i = 1:length(Data_Calib)
figure(i); title(run_names{i})
for j = 1:3
subplot(1,3,j);
freq_hist{i,j} = histc(trans_pos_pwrCutoff{i,j}, 0:1.5:20) / ...
length(trans_pos_pwrCutoff{i,j});
bar(0:2:25, freq_hist{i,j}); axis([0 25 0 0.3]);
title(names{j}); xlabel('Frequency'); ylabel('Percent Transients');
end
ha = axes('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1], 'Box', ...
'off','Visible','off','Units','normalized', 'clipping' , 'off');
text(0.5, 1,run_names{i},'HorizontalAlignment', ...
'center','VerticalAlignment', 'top')
end
for i = 1:length(Data_Calib)
figure(i + length(Data_Calib)); title(run_names{i})
for j = 1:3
subplot(1,3,j);
vel_hist{i,j} = histc(max_vels{i,j}, 0:75:600) / ...
length(max_vels{i,j});
bar(0:75:600, vel_hist{i,j}); axis([0 650 0 0.5]);
title(names{j}); xlabel('Max Velocity');
ylabel('Percent Transients');
end
ha = axes('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1], 'Box', ...
'off','Visible','off','Units','normalized', 'clipping' , 'off');
text(0.5, 1,run_names{i},'HorizontalAlignment', ...
'center','VerticalAlignment', 'top')
end