-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlotCorrelationDelay.m~
97 lines (85 loc) · 2.78 KB
/
PlotCorrelationDelay.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
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
90
91
92
93
94
95
96
97
% make figure demonstrating correlation between roll and yaw as function of
% delay.
% first, run ReadAndProcessYEIData.m or ReadRotateAndProcessYEIData.m so
% that you have a "FilteredData" struct.
%{
%subject 1:
begin: 55
end: 102
subject 2:
%}
%{
for subject 10
Begin1 = 404;
End1 = 419;
Begin2 = 398;
End2 = 398;
%}
%{
%for subject 6
Begin1 = 207;
End1 = 221;
Begin2 = 193;
End2 = 195;
%}
% for subject 5
Begin1 = 55;
End1 = 102;
Begin2 = 103;
End2 = 105;
% WalkRun
Begin1 = 441;
End1 = 580;
Begin2 = 581;
End2 = 582;
MaxCorrelationsUnconstrained = zeros(length(Begin1:End1), 1);
close; clear Correlation;
for RunNumber = Begin1:End1
FilteredData(RunNumber).Filename
% make sure it's an interesting run in unconstrained conditions.
MaxOffset = 125;
for Offset = 1:MaxOffset
tmp = corrcoef(FilteredData(RunNumber).YGyro, ...
circshift(FilteredData(RunNumber).ZGyro', Offset)');
Correlation(Offset) = tmp(2, 1);
end
MaxCorrelationsUnconstrained(RunNumber - Begin1 + 1) = max(Correlation);
DelayIndices = 1:MaxOffset;
TimeStepVector = FilteredData(RunNumber).TimeInSeconds - ...
circshift(FilteredData(RunNumber).TimeInSeconds', 1)';
MeanTimeStep = mean(TimeStepVector(2:end));
DelayInSeconds = DelayIndices .* MeanTimeStep;
plot(DelayInSeconds, Correlation, 'LineWidth', 2);
ylim([-0.2 1])
title(strcat('Correlation Between Roll and Pitch as Function of Delay', ...
FilteredData(RunNumber).Filename) );
%'FontSize', 16)
xlabel('Delay (s)', 'FontSize', 14)
ylabel('Correlation', 'FontSize', 14)
% pause(0.5);
end
MaxCorrelationsRIP = zeros(length(Begin2:End2), 1);
for RunNumber = Begin2:End2
MaxOffset = 125;
for Offset = 1:MaxOffset
tmp = corrcoef(FilteredData(RunNumber).XGyro, ...
circshift(FilteredData(RunNumber).YGyro', Offset)');
Correlation(Offset) = tmp(2, 1);
end
MaxCorrelationsRIP(RunNumber - Begin2 + 1) = max(Correlation);
DelayIndices = 1:MaxOffset;
TimeStepVector = FilteredData(RunNumber).TimeInSeconds - ...
circshift(FilteredData(RunNumber).TimeInSeconds', 1)';
MeanTimeStep = mean(TimeStepVector(2:end));
DelayInSeconds = DelayIndices .* MeanTimeStep;
plot(DelayInSeconds, Correlation, 'LineWidth', 2);
ylim([-0.2 1])
title(strcat('Correlation Between Roll and Pitch as Function of Delay', ...
FilteredData(RunNumber).Filename) );
%'FontSize', 16)
xlabel('Delay (s)', 'FontSize', 14)
ylabel('Correlation', 'FontSize', 14)
end
MaxCorrelationsUnconstrained
MaxCorrelationsRIP
[Diff P ] = ttest2(MaxCorrelationsUnconstrained, MaxCorrelationsRIP)