-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfigure7.m
More file actions
236 lines (207 loc) · 6.22 KB
/
figure7.m
File metadata and controls
236 lines (207 loc) · 6.22 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
function figure7(zdiff_rot_comp,zdiff_flap_comp,zdiff_flaprot_comp,T,zdisp_fnr, zdisp_fr, zdisp_nfr,t)
% Plotting Figure 6
fig_pos = [25,25, 700,500];
h = figure('Position',fig_pos,'Color',[1 1 1]);
set(h,'DefaultTextFontSize',11)
set(h,'DefaultAxesFontsize',11)
set(h,'DefaultTextFontName','Times')
set(h,'DefaultAxesFontName','Times')
%% Computational results
% Find peaks in data so time averaging can be done accurately
P=findpeaks(1:length(zdiff_flap_comp),zdiff_flaprot_comp,0,-5,20,5,3);
index = 1;
for k = 10:10:length(P(:,2))-10
i = round(P(k,2));
j = i+332;
rot(:,index) = (zdiff_rot_comp(i:j));
flap(:,index) = (zdiff_flap_comp(i:j));
flaprot(:,index) = (zdiff_flaprot_comp(i:j));
index = index +1;
end
% Take average of results over each rotation cycle
avg_r = mean(rot');
std_r = std(rot',0);
avg_f = mean(flap');
std_f = std((flap'),0);
avg_fr = mean(flaprot');
std_fr = std(flaprot',0);
% Put into matrix for rotating alone, flapping alone, and flapping and rotating
zdiff_comp(1,:) = avg_r;
zdiff_comp(2,:) = avg_f;
zdiff_comp(3,:) = avg_fr;
zdiff_std_comp(1,:) = std_r;
zdiff_std_comp(2,:) = std_f;
zdiff_std_comp(3,:) = std_fr;
% Plot results
hold on
subplot(3,2,1)
boundedline(T(1:333),zdiff_comp(2,:)*100,zdiff_std_comp(2,:)*100,'b')
axis([0 0.33 -.3e-1 .3e-1])
text(0.08,0.045,'Computational Results','FontName','Times')
ylabel('\epsilon_x_y_,_F (%)','FontName','Times')
h=text(-0.08,0.035,'(a)');
set(h,'FontName','Times')
xlabel('t (s)','FontName','Times')
set(gca,'YTick',[-0.02,0,0.02])
subplot(3,2,3)
boundedline(T(1:333),zdiff_comp(3,:)*100,zdiff_std_comp(3,:)*100,'g')
axis([0 0.33 -.3e-1 .3e-1])
ylabel('\epsilon_x_y_,_F_&_R (%)','FontName','Times')
xlabel('t (s)','FontName','Times')
h=text(-0.08,0.035,'(b)');
set(h,'FontName','Times')
set(gca,'YTick',[-0.02,0,0.02])
%%
Fs = 1000;
L = length(zdiff_comp(1,:));
NFFT = 2^nextpow2(L);
f = Fs/2*linspace(0,1,NFFT/2+1);
for i = 1:6
Y_nfr(:,i) = fft(rot(:,i)-mean(rot(:,i)),NFFT)/L;
Y_fr(:,i) = fft(flaprot(:,i)-mean(flaprot(:,i)),NFFT)/L;
Y_fnr(:,i) = fft(flap(:,i)-mean(flap(:,i)),NFFT)/L;
end
Z_nfr = mean(abs(Y_nfr),2);
stdZ_nfr = std(abs(Y_nfr),0,2);
Z_fr = mean(abs(Y_fr),2);
stdZ_fr = std(abs(Y_fr),0,2);
Z_fnr = mean(abs(Y_fnr),2);
stdZ_fnr = std(abs(Y_fnr),0,2);
%%
Fs = 1000;
L = length(zdiff_rot_comp);
NFFT = (L);
f = Fs/2*linspace(0,1,NFFT/2+1);
Y_tot_fr = fft((zdiff_flaprot_comp-mean(zdiff_flaprot_comp)),NFFT)/L;
Y_tot_fnr = fft((zdiff_flap_comp-mean(zdiff_flaprot_comp)),NFFT)/L;
%%
subplot(3,2,5)
plot(f,(2*abs(Y_tot_fr(1:NFFT/2+1))-2*abs(Y_tot_fnr(1:NFFT/2+1)))*100,'k')
axis([0 100 -3e-4 3e-4])
h=text(-24.24,3.5e-4,'(c)');
set(h,'FontName','Times')
%% Experimental results
clear rot flap flaprot zdiff_comp zdiff_std_comp
% Plot experimental results
P=findpeaks(1:length(zdisp_fr),zdisp_fr,0,-5,20,5,3);
index = 1;
for k = 10:10:length(P(:,2))-10
i = round(P(k,2));
j = i+1667;
rot(:,index) = detrend((zdisp_nfr(i:j)-mean(zdisp_nfr)));
flap(:,index) = detrend((zdisp_fnr(i:j)-mean(zdisp_fnr)));
flaprot(:,index) = detrend((zdisp_fr(i:j)-mean(zdisp_fr)));
index = index +1;
end
% Take average of results over each rotation cycle
avg_r = mean(rot');
std_r = std(rot',0);
avg_f = mean(flap');
std_f = std((flap'),0);
avg_fr = mean(flaprot');
std_fr = std(flaprot',0);
% Put into matrix for rotating alone, flapping alone, and flapping and rotating
zdiff_comp(1,:) = avg_r;
zdiff_comp(2,:) = avg_f;
zdiff_comp(3,:) = avg_fr;
zdiff_std_comp(1,:) = std_r;
zdiff_std_comp(2,:) = std_f;
zdiff_std_comp(3,:) = std_fr;
% Plot results
hold on
subplot(3,2,2)
boundedline(t(1:1668),zdiff_comp(2,:)*100,zdiff_std_comp(2,:)*100,'b')
axis([0 0.33 -.3e-1 .3e-1])
h=text(0.08,0.045,'Experimental Results');
set(h,'FontName','Times')
h=text(-0.05,0.035,'(d)');
set(h,'FontName','Times')
set(gca,'YTick',[-0.02,0,0.02])
set(gca,'YTickLabel',[])
xlabel('t (s)','FontName','Times')
subplot(3,2,4)
boundedline(t(1:1668),zdiff_comp(3,:)*100,zdiff_std_comp(3,:)*100,'g')
axis([0 0.33 -.3e-1 .3e-1])
xlabel('t (s)','FontName','Times')
h=text(-0.05,0.035,'(e)');
set(h,'FontName','Times')
set(gca,'YTick',[-0.02,0,0.02])
set(gca,'YTickLabel',[])
%%
clear Y_nfr Y_fr Y_fnr
Fs = 1000;
L = length(zdiff_comp(1,:));
NFFT = (L);
f = Fs/2*linspace(0,1,NFFT/2+1);
for i = 1:6
Y_nfr(:,i) = fft(detrend(rot(:,i)-mean(rot(:,i))),NFFT)/L;
Y_fr(:,i) = fft(detrend(flaprot(:,i)-mean(flaprot(:,i))),NFFT)/L;
Y_fnr(:,i) = fft(detrend(flap(:,i)-mean(flap(:,i))),NFFT)/L;
end
Z_nfr = mean(abs(Y_nfr),2);
stdZ_nfr = std(abs(Y_nfr),0,2);
Z_fr = mean(abs(Y_fr),2);
stdZ_fr = std(abs(Y_fr),0,2);
Z_fnr = mean(abs(Y_fnr),2);
stdZ_fnr = std(abs(Y_fnr),0,2);
%%
dt = mean(diff(t(1:end)));
Fs = 1/dt;
L = length(t(1:end));
NFFT = L/2;%2^nextpow2(L);
f = Fs/2*linspace(0,1,NFFT/2+1);
Y_flap = fft((zdisp_fnr(1:end,:,:)-mean(zdisp_fnr)),NFFT)/L;
Y_flaprot = fft((zdisp_fr(1:end,:,:)-mean(zdisp_fr)),NFFT)/L;
Y_rot = fft((zdisp_nfr(1:end,:,:)-mean(zdisp_nfr)),NFFT)/L;
%%
subplot(3,2,6)
min = -3e-4;
max = 3e-4;
axis([0 100 min max])
plot(f,(2*abs(Y_flaprot(1:NFFT/2+1))-2*abs(Y_flap(1:NFFT/2+1)))*100,'k')
axis([0 100 min max])
h=text(-14.24,3.5e-4,'(f)');
set(h,'FontName','Times')
xlabel('f (Hz)','FontName','Times')
set(gca,'XTick',[22 28 47 53 72 78])
h = line([22 22],[min max]);
set(h,'LineStyle','--');
set(h,'Color','r')
h = line([28 28],[min max]);
set(h,'LineStyle','--');
set(h,'Color','r')
h=line([47 47],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
h=line([53 53],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
h=line([72 72],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
h=line([78 78],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
set(gca,'YTickLabel',[])
subplot(3,2,5)
xlabel('f (Hz)','FontName','Times')
ylabel('|F[\epsilon_x_y_,_F_&_R] - F[\epsilon_x_y_,_F]| (%)','FontName','Times')
set(gca,'XTick',[22 28 47 53 72 78])
h = line([22 22],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
h = line([28 28],[min max]);
set(h,'LineStyle','--');
set(h,'Color','r')
h=line([47 47],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
h=line([53 53],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
h=line([72 72],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')
h=line([78 78],[min max]);
set(h,'LineStyle','--')
set(h,'Color','r')