-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWingAnglesCalcMulti.m
More file actions
executable file
·202 lines (167 loc) · 6.05 KB
/
WingAnglesCalcMulti.m
File metadata and controls
executable file
·202 lines (167 loc) · 6.05 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
close all; clear all; clc
expname = ['WingAngles_exp098c';
'WingAngles_exp101c';
'WingAngles_exp099c';
'WingAngles_exp100c';
'WingAngles_exp102c';
'WingAngles_exp104c';
'WingAngles_exp083c';
'WingAngles_exp035c';
];
expnum = [36;
39;
37;
38;
40;
42;
24;
6;
];
wbeats = [ 5 10 14 17 22 26 31 0 0 0;
5 10 14 17 21 25 28 32 35 40;
3 7 10 14 18 21 25 29 33 36;
6 10 14 18 0 0 0 0 0 0;
20 24 27 31 35 39 43 46 49 53;
22 25 30 34 0 0 0 0 0 0;
1 4 6 8 10 14 0 0 0 0;
];
stp = 1/6;
wbeats = wbeats./stp;
wbeatsnum = [ 7;
10;
10;
4;
10;
4;
6;
];
color = ['r:';'b:';'g:';'m:';'c:';'r:';'b:';'g:'];
load gmc/Combo2Results_n.mat
scrsz = get(0,'ScreenSize');
SAmp = figure('Position',[1 scrsz(4)*0.6 scrsz(3)/6 scrsz(4)*0.4]);
SPD = figure('Position',[1 1 scrsz(3)/6 scrsz(4)*0.4]);
BO = figure('Position',[scrsz(3)/6 1 scrsz(3)/6 scrsz(4)*0.4]);
AoA = figure('Position',[scrsz(3)/6 scrsz(4)*0.6 scrsz(3)/6 scrsz(4)*0.4]);
WBF = figure('Position',[scrsz(3)*2/6 scrsz(4)*0.6 scrsz(3)/6 scrsz(4)*0.4]);
Amp = figure('Position',[scrsz(3)*2/6 1 scrsz(3)/6 scrsz(4)*0.4]);
%GMC = figure('Position',[scrsz(3)*3/6 scrsz(4)*0.6 scrsz(3)/6 scrsz(4)*0.4]);
for ij = 1
load(expname(ij,:))
%% %===================
%Plot wing angles
%t_end = movidx(end);
%===================
%Plot Stroke Amplitude
%tt = movidx;
t_end = round(tt(end));
figure(SAmp);
plot(tt,phi_R*(180/pi),'r-','linewidth',2);
hold on
plot(tt,phi_L*(180/pi),'b-','linewidth',2);
set(gca,'plotboxaspectratio',[3 1 1],'xlim',[tt(1) t_end]);
set(gca,'ylim',[-110 110],'ytick',-110:55:110,'yticklabel',{'-110','','0','','110'});
hold off
%===================
%Plot Stroke Plane Deviation (w.r.t. 62deg)
figure(SPD);
plot(tt,theta_R*(180/pi),'r-','linewidth',2);
hold on
plot(tt,theta_L*(180/pi),'b-','linewidth',2);
set(gca,'plotboxaspectratio',[3 1 1],'xlim',[tt(1) t_end]);
set(gca,'ylim',[-40 40],'ytick',-40:20:40,'yticklabel',{'-40','','0','','40'});
hold off
%===================
%Plot Angle of Attack (geometric)
figure(AoA)
plot(tt(1:end-1),alpha_R(1:end-1)*(180/pi),'r-','linewidth',2);
hold on
plot(tt(1:end-1),alpha_L(1:end-1)*(180/pi),'b-','linewidth',2);
set(gca,'plotboxaspectratio',[3 1 1],'xlim',[tt(1) t_end]);
set(gca,'ylim',[-180 180],'ytick',-180:90:180,'yticklabel',{'-180','','0','','180'});
hold off
%===================
%Plot Body orientation
figure(BO);
plot(tt,BodyAng_auto(1,:)*(180/pi),'r-','linewidth',2);
hold on;
plot(tt,BodyAng_auto(2,:)*(180/pi),'g-','linewidth',2);
plot(tt,(BodyAng_auto(3,:) - BodyAng_auto(3,1))*(180/pi),'b-','linewidth',2);
set(gca,'plotboxaspectratio',[3 1 1],'xlim',[tt(1) t_end]);
box off
hold off
%===================
%Wingbeat Frequency
[maxAmpR, minAmpR] = peakdet(phi_R, 0.1, tt);
[maxAmpL, minAmpL] = peakdet(phi_L, 0.1, tt);
figure(SAmp); hold on
plot(minAmpR(:,1), minAmpR(:,2).*180/pi, 'g*');
plot(minAmpL(:,1), minAmpL(:,2).*180/pi, 'y*');
plot(maxAmpR(:,1), maxAmpR(:,2).*180/pi, 'r*');
plot(maxAmpL(:,1), maxAmpL(:,2).*180/pi, 'm*');
hold off
for ik=1:length(minAmpR(:,2))-1
wbfR(1,ik) = 1/(minAmpR(ik+1,1)-minAmpR(ik,1))*1000;
end
for ik=1:length(minAmpL(:,2))-1
wbfL(1,ik) = 1/(minAmpL(ik+1,1)-minAmpL(ik,1))*1000;
end
wbfR = [wbfR(1,1) wbfR];
wbfL = [wbfL(1,1) wbfL];
figure(WBF);
plot(minAmpR(:,1)-minAmpR(1,1),wbfR,color(ij,:),'LineWidth',2); hold on
plot(minAmpR(:,1)-minAmpR(1,1),wbfR,'kx','LineWidth',2)
plot(minAmpL(:,1)-minAmpR(1,1),wbfL,color(ij,:),'LineWidth',2)
plot(minAmpL(:,1)-minAmpR(1,1),wbfL,'ko','LineWidth',1.2)
set(gca,'plotboxaspectratio',[3 1 1]);
set(gca,'xlim',[0 40])
%set(gca,'ylim',[0 300],'ytick',0:100:300,'yticklabel',{'0','','','300'});
%if they occurr subsequently in time
for iii = 1:length(minAmpR(:,1))-1
for jjj = 1:length(maxAmpR(:,1))
if (maxAmpR(jjj,1)>minAmpR(iii,1))&&(maxAmpR(jjj,1)<minAmpR(iii+1,1))
A(iii) = (maxAmpR(jjj,2) - minAmpR(iii,2)).*180/pi;
break;
end
end
end
for iii = 1:length(minAmpL(:,1))-1
for jjj = 1:length(maxAmpL(:,1))
if (maxAmpL(jjj,1)>minAmpL(iii,1))&&(maxAmpL(jjj,1)<minAmpL(iii+1,1))
B(iii) = (maxAmpL(jjj,2) - minAmpL(iii,2)).*180/pi;
break;
end
end
end
figure(Amp)
plot(1:length(A),A,color(ij,:),'LineWidth',2);hold on
plot(1:length(A),A,'kx','LineWidth',2)
plot(1:length(B),B,color(ij,:),'LineWidth',2)
plot(1:length(B),B,'ko','LineWidth',1.2)
set(gca,'plotboxaspectratio',[3 1 1]);
set(gca,'xtick',1:1:length(A),'xticklabel',{'1','2','3','4','5','6','7','8','9'});
box off
clear wbfR wbfL
% idbeg = find(allData(expnum(ij)).f_align==0);
% idend = length(allData(expnum(ij)).f_align);
%figure(GMC);
% figure(BO); hold on
%gtime = allData(expnum(ij)).f_align(idbeg:idend)./6;
%plot(gtime,allData(expnum(ij)).exp.rpy(1,idbeg:idend).*-180/pi,'r:','linewidth',2);
%hold on
%plot(gtime,allData(expnum(ij)).exp.rpy(2,idbeg:idend).*180/pi,'g:','linewidth',2);
%plot(gtime,allData(expnum(ij)).exp.rpy(3,idbeg:idend).*180/pi,'b:','linewidth',2);
%hold off
%set(gca,'plotboxaspectratio',[3 1 1]);
end
figure(SAmp);
title('S.Amp');box off
figure(SPD);
title('S.P.D');box off
figure(BO);
title('B.O:E - roll(r), pitch(g), yaw(b)');box off
figure(AoA);
title('A-o-A');box off
figure(WBF);
title('WBF');box off
%figure(GMC);
%title('B.O:G - idem');box off