diff --git a/utils/analysis/plotcf.m b/utils/analysis/plotcf.m index 2e6d6630841fd11f4c4f55835f918ba70aad17f4..d301548a43a0ba30dc90ce84fed9ee8afcdecfdf 100644 --- a/utils/analysis/plotcf.m +++ b/utils/analysis/plotcf.m @@ -21,33 +21,39 @@ function plotcf(ResData) OFFSET_STEPS = 20; CHORD = 0.05; INTERESTING_PLOTS = [ - 0.03, 2, 7.7 - 0.03, 2, 7.7 - 0.03, 3, 2.5 + 0.03, 3, 4.6 - 0.03, 3.5, 2.5 0.03, 3.5, 4.6 - 0.03, 3.5, 7.7 - - % 0.05, 1.25, 4.6 % DRIFT ON INERTIA - 0.05, 2, 7.7 - 0.05, 3, 7.7 - 0.05, 3.5, 2.5 - 0.05, 3.5, 7.7 - - 0.10, 2.5, 4.6 - 0.10, 2.5, 7.7 - 0.10, 3.5, 2.5 - 0.10, 3.5, 4.6 - 0.10, 3.5, 7.7 + 0.03, 3, 7.7 + 0.10, 3, 7.7 + + % 0.03, 2, 7.7 + % 0.03, 2, 7.7 + % 0.03, 3, 2.5 + % 0.03, 3.5, 2.5 + % 0.03, 3.5, 7.7 + % + % % 0.05, 1.25, 4.6 % DRIFT ON INERTIA + % 0.05, 2, 7.7 + % 0.05, 3, 7.7 + % 0.05, 3.5, 2.5 + % 0.05, 3.5, 7.7 + % + % 0.10, 2.5, 4.6 + % 0.10, 2.5, 7.7 + % 0.10, 3.5, 2.5 + % 0.10, 3.5, 4.6 + % 0.10, 3.5, 7.7 ]; - SAVE_TIKZ_PARAM = [0, 0, 0]; % Points to save ([0,0,0] to make sur nothing is save) + SAVE_TIKZ_PARAM = []; % Points to save ([0,0,0] to make sur nothing is save) - for i = 1:size(ResData, 1) - for j = 1:size(ResData, 2) + for j = 1:size(ResData, 2) + for i = 1:size(ResData, 1) - if isinteresting(ResData(i, j), INTERESTING_PLOTS) + if isinteresting(ResData(i, j), INTERESTING_PLOTS) && ... + ~(ResData(i, j).Testcase.dx == 0.05 && ResData(i, j).Testcase.freq <= 2) && ... + ~(ResData(i, j).Testcase.dx == 0.03 && ResData(i, j).Testcase.freq == 1.25) trueF = ResData(i, j).Front.trueFreq; @@ -55,12 +61,13 @@ function plotcf(ResData) expParam = sprintf('d = %0.2f, f = %0.2f, V = %0.1f (k = %0.02f)', ... ResData(i, j).Testcase.dx, ... - ResData(i, j).Testcase.freq, ... + ResData(i, j).Front.trueFreq, ... ResData(i, j).Testcase.airspeed, ... redFreq); offsets = ResData(i, j).AllPhases.offsets; - cleanOffsets = -175:OFFSET_STEPS:175; + offsets = wrapTo360(offsets); % Wrap offsets in [0,360]; + cleanOffsets = OFFSET_STEPS / 2:OFFSET_STEPS:360 - OFFSET_STEPS / 2; meanOffset = nan(size(cleanOffsets)); stdOffset = nan(size(cleanOffsets)); for iOff = 1:length(cleanOffsets) @@ -91,15 +98,16 @@ function plotcf(ResData) plot(ResData(i, j).AllPhases.offsets, ... ResData(i, j).AllPhases.Front.cF(:, [1, 3]), 'o'); end - errorbar(cleanOffsets, meanF(:, 3), yposF(:, 3), 'o', 'Capsize', ERR_CAPSIZE); - errorbar(cleanOffsets, meanF(:, 1), yposF(:, 1), 'o', 'Capsize', ERR_CAPSIZE); + e1 = errorbar(cleanOffsets, meanF(:, 3), yposF(:, 3), 's', 'Capsize', ERR_CAPSIZE); + e2 = errorbar(cleanOffsets, meanF(:, 1), yposF(:, 1), 'o', 'Capsize', ERR_CAPSIZE); + e1.MarkerFaceColor = e1.Color; + e2.MarkerFaceColor = e2.Color; hold off; setgca('XTickLabel', [], ... 'XLabel', []); legend({'\cl', '\cd'}, 'Location', 'SouthWest'); legend('boxoff'); - ax1.Position(3) = 1.25 * ax1.Position(3); - title('Front'); + % ax1.Position(3) = 1.25 * ax1.Position(3); ax2 = subplot(212); setcolormap(); @@ -108,17 +116,28 @@ function plotcf(ResData) plot(ResData(i, j).AllPhases.offsets, ... ResData(i, j).AllPhases.Aft.cF(:, [1, 3]), 'o'); end - errorbar(cleanOffsets, meanA(:, 3), yposA(:, 3), 'o', 'Capsize', ERR_CAPSIZE); - errorbar(cleanOffsets, meanA(:, 1), yposA(:, 1), 'o', 'Capsize', ERR_CAPSIZE); + e3 = errorbar(cleanOffsets, meanA(:, 3), yposA(:, 3), 's', 'Capsize', ERR_CAPSIZE); + e4 = errorbar(cleanOffsets, meanA(:, 1), yposA(:, 1), 'o', 'Capsize', ERR_CAPSIZE); + e3.MarkerFaceColor = e3.Color; + e4.MarkerFaceColor = e4.Color; hold off; - title(ax2, 'Aft'); setgca(); linkaxes([ax1 ax2], 'xy'); ax2.Position(3) = ax1.Position(3); - title('Aft'); + + % Add annotations + + % Increase axes Y lim by 10% of the data range before writing text + FACTOR = 0.1; + + yDiff = diff(ax1.YLim); + ax1.YLim = [ax1.YLim(1), ax1.YLim(2) + FACTOR * yDiff]; + addtxt(ax1, '\bf Front', ax1.YLim(2)); + addtxt(ax2, '\bf Aft', ax2.YLim(2)); if isinteresting(ResData(i, j), SAVE_TIKZ_PARAM) + pause(1); figdir = 'figures/results/'; filename = sprintf('flapWindOn-Dx%0.2f_F%0.2f_V%0.1f.tex', ... ResData(i, j).Testcase.dx, ... @@ -142,37 +161,78 @@ function plotcf(ResData) end % Plot aft wings only for different spacing conditions - for j = 26 + for j = 24 figure('Name', 'Dx'); - ax1 = subplot(211); + ax1 = subplot(221); setcolormap(); hold on; - errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 3), Tmp(2, j).stdA(:, 3), 'o', ... - 'Capsize', ERR_CAPSIZE); - errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 1), Tmp(2, j).stdA(:, 1), 'o', ... - 'Capsize', ERR_CAPSIZE); + e11 = errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanF(:, 3), Tmp(2, j).stdF(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + e12 = errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanF(:, 1), Tmp(2, j).stdF(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + e11.MarkerFaceColor = e11.Color; + e12.MarkerFaceColor = e12.Color; hold off; setgca('XTickLabel', [], ... 'XLabel', []); - title('$\dx = 0.03 \unit{\m}$'); - legend({'\cl', '\cd'}, 'Location', 'NorthEast'); + + legend({'\cl', '\cd'}, 'Location', 'SouthWest'); legend('boxoff'); - ax1.Position(3) = 1.25 * ax1.Position(3); - ax2 = subplot(212); + ax2 = subplot(222); + setcolormap(); + hold on; + e21 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanF(:, 3), Tmp(1, j).stdF(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + e22 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanF(:, 1), Tmp(1, j).stdF(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + e21.MarkerFaceColor = e21.Color; + e22.MarkerFaceColor = e22.Color; + hold off; + setgca('XTickLabel', [], ... + 'XLabel', [], ... + 'YTickLabel', [], ... + 'YLabel', []); + + ax3 = subplot(223); setcolormap(); hold on; - errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... - 'Capsize', ERR_CAPSIZE); - errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... - 'Capsize', ERR_CAPSIZE); + e31 = errorbar(Tmp(1, j).cleanOffsets, Tmp(2, j).meanA(:, 3), Tmp(2, j).stdA(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + e32 = errorbar(Tmp(1, j).cleanOffsets, Tmp(2, j).meanA(:, 1), Tmp(2, j).stdA(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + e31.MarkerFaceColor = e31.Color; + e32.MarkerFaceColor = e32.Color; hold off; setgca(); - title('$\dx = 0.10 \unit{\m}$'); - linkaxes([ax1 ax2], 'xy'); - ax2.Position(3) = ax1.Position(3); + ax4 = subplot(224); + setcolormap(); + hold on; + e41 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... + 'Capsize', ERR_CAPSIZE); + e42 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... + 'Capsize', ERR_CAPSIZE); + e41.MarkerFaceColor = e41.Color; + e42.MarkerFaceColor = e42.Color; + hold off; + setgca('YTickLabel', [], ... + 'YLabel', []); + + linkaxes([ax1 ax2 ax3 ax4], 'xy'); + + % Add annotations + % Increase axes Y lim by 10% of the data range before writing text + FACTOR = 0.1; + + yDiff = diff(ax1.YLim); + ax1.YLim = [ax1.YLim(1), ax1.YLim(2) + FACTOR * yDiff]; + addtxt(ax1, '$\mathbf{\dx}$ = 0.03 m (Front)', ax1.YLim(2)); + addtxt(ax2, '$\mathbf{\dx}$ = 0.10 m (Aft)', ax2.YLim(2)); + addtxt(ax3, '$\mathbf{\dx}$ = 0.03 m (Front)', ax3.YLim(2)); + addtxt(ax4, '$\mathbf{\dx}$ = 0.10 m (Aft)', ax4.YLim(2)); + pause(1); figdir = 'figures/results/'; filename = sprintf('flapWindOn-DxCompa-F%0.2f_V%0.1f.tex', ... ResData(i, j).Testcase.freq, ... @@ -181,53 +241,95 @@ function plotcf(ResData) end - % Plot aft wings only for diff frequencies - j = 20; - figure('Name', 'K'); - ax1 = subplot(211); - setcolormap(); - hold on; - errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... - 'Capsize', ERR_CAPSIZE); - errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... - 'Capsize', ERR_CAPSIZE); - hold off; - setgca('XTickLabel', [], ... - 'XLabel', []); - title('$\redFreq = 0.05$'); - legend({'\cl', '\cd'}, 'Location', 'NorthEast'); - legend('boxoff'); - ax1.Position(3) = 1.25 * ax1.Position(3); - - j = 28; - ax2 = subplot(212); - setcolormap(); - hold on; - errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... - 'Capsize', ERR_CAPSIZE); - errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... - 'Capsize', ERR_CAPSIZE); - hold off; - setgca(); - title('$\redFreq = 0.07$'); - linkaxes([ax1 ax2], 'x'); - ax2.Position(3) = ax1.Position(3); - - figdir = 'figures/results/'; - filename = sprintf('flapWindOn-kCompa-Dx%0.2f_V%0.1f.tex', ... - ResData(i, j).Testcase.dx, ... - ResData(i, j).Testcase.airspeed); - save2tikz([figdir, filename], '\small'); + % % Plot aft wings only for different spacing conditions + % for j = 26 + % + % figure('Name', 'Dx'); + % ax1 = subplot(211); + % setcolormap(); + % hold on; + % errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 3), Tmp(2, j).stdA(:, 3), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 1), Tmp(2, j).stdA(:, 1), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % hold off; + % setgca('XTickLabel', [], ... + % 'XLabel', []); + % title('$\dx = 0.03 \unit{\m}$'); + % legend({'\cl', '\cd'}, 'Location', 'NorthEast'); + % legend('boxoff'); + % ax1.Position(3) = 1.25 * ax1.Position(3); + % + % ax2 = subplot(212); + % setcolormap(); + % hold on; + % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % hold off; + % setgca(); + % title('$\dx = 0.10 \unit{\m}$'); + % linkaxes([ax1 ax2], 'xy'); + % ax2.Position(3) = ax1.Position(3); + % + % figdir = 'figures/results/'; + % filename = sprintf('flapWindOn-DxCompa-F%0.2f_V%0.1f.tex', ... + % ResData(i, j).Testcase.freq, ... + % ResData(i, j).Testcase.airspeed); + % save2tikz([figdir, filename], '\small'); + % + % end + % + % % Plot aft wings only for diff frequencies + % j = 20; + % figure('Name', 'K'); + % ax1 = subplot(211); + % setcolormap(); + % hold on; + % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % hold off; + % setgca('XTickLabel', [], ... + % 'XLabel', []); + % title('$\redFreq = 0.05$'); + % legend({'\cl', '\cd'}, 'Location', 'NorthEast'); + % legend('boxoff'); + % ax1.Position(3) = 1.25 * ax1.Position(3); + % + % j = 28; + % ax2 = subplot(212); + % setcolormap(); + % hold on; + % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... + % 'Capsize', ERR_CAPSIZE); + % hold off; + % setgca(); + % title('$\redFreq = 0.07$'); + % linkaxes([ax1 ax2], 'x'); + % ax2.Position(3) = ax1.Position(3); + % + % figdir = 'figures/results/'; + % filename = sprintf('flapWindOn-kCompa-Dx%0.2f_V%0.1f.tex', ... + % ResData(i, j).Testcase.dx, ... + % ResData(i, j).Testcase.airspeed); + % save2tikz([figdir, filename], '\small'); end function setgca(varargin) - xlim([-180, 180]); + % xlim([-180, 180]); + xlim([0, 360]); xlabel('Phase offset [deg]'); ylabel('\cl and \cd [-]'); - xticks([-180:90:180]); + % xticks([-180:90:180]); + xticks([0:90:360]); set(gca, ... 'Box', 'off', ... @@ -251,3 +353,10 @@ function setgca(varargin) end end + +function addtxt(ax, txt, ypos) + + text(ax, 10, ypos, ... + txt, ... + 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top', 'FontWeight', 'bold'); +end