diff --git a/utils/plotwindonoff.m b/utils/plotwindonoff.m index d9cb7874a1a10d2f909f632525313a347ea846ee..f5ef548527f17adb60ba5fce9d16677a3588f0ae 100644 --- a/utils/plotwindonoff.m +++ b/utils/plotwindonoff.m @@ -15,7 +15,11 @@ function plotwindonoff(ResData) 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.10, 3.5, 7.7 + ]; + + PLOT_TIME = false; + SAVE_TIKZ_PARAM = INTERESTING_POINTS(2, :); for i = 1:size(ResData, 1) for j = 1:size(ResData, 2) @@ -51,44 +55,54 @@ function plotwindonoff(ResData) period = 1 / windOff.trueFreq; nPeriodIdx = period * sampling; - time = (0:length(meanDiff) - 1) / nPeriodIdx; - - figure; - hold on; - plot(time, meanPeakFoff); - plot(time, meanPeakFon); - plot(time, meanDiff); - yyaxis right; - plot(time, meanPeakAngle); - title(expParam); - legend('Wind off', 'Wind on', 'Diff'); - grid on; - xlim([0, 1]); + if PLOT_TIME + time = (0:length(meanDiff) - 1) / nPeriodIdx; + + figure; + hold on; + plot(time, meanPeakFoff); + plot(time, meanPeakFon); + plot(time, meanDiff); + yyaxis right; + plot(time, meanPeakAngle); + title(expParam); + legend('Wind off', 'Wind on', 'Diff'); + grid on; + xlim([0, 1]); + end figure; ax1 = subplot(3, 1, 1); hold on; plot(meanPeakAngle, meanPeakFon); - plot(meanPeakAngle(round(end / 5)), meanPeakFon(round(end / 5)), 'or'); - - title(['Wind on - ', expParam]); + % plot(meanPeakAngle(round(end / 5)), meanPeakFon(round(end / 5)), 'or'); + setgca(); + set(gca, 'XTickLabel', []); ax2 = subplot(3, 1, 2); hold on; - plot(meanPeakAngle, meanPeakFoff); - plot(meanPeakAngle(round(end / 5)), meanPeakFoff(round(end / 5)), 'or'); - - title(['Wind off - ', expParam]); + % plot(meanPeakAngle(round(end / 5)), meanPeakFoff(round(end / 5)), 'or'); + setgca(); + set(gca, 'XTickLabel', []); ax3 = subplot(3, 1, 3); hold on; plot(meanPeakAngle, meanDiff); - plot(meanPeakAngle(round(end / 5)), meanDiff(round(end / 5)), 'or'); - title(['Diff - ', expParam]); + % plot(meanPeakAngle(round(end / 5)), meanDiff(round(end / 5)), 'or'); linkaxes([ax1 ax2 ax3], 'xy'); ax1.YLim = 1.25 * ax1.YLim; + setgca(); + xlabel('Flapping angle [deg]'); + + if isinteresting(ResData(i, j), SAVE_TIKZ_PARAM) + save2tikz('figures/test.tex', '\small'); + else + title(ax1, ['Wind on - ', expParam]); + title(ax2, ['Wind off - ', expParam]); + title(ax3, ['Diff - ', expParam]); + end end @@ -115,3 +129,24 @@ function meanPeak = averagepeaks(signal, sampling, freq) meanPeak = mean(peakVals); end + +function setgca() + set(gca, ... + 'Box', 'off', ... + 'TickDir', 'out', ... + 'TickLength', [.02 .02], ... + 'XMinorTick', 'off', ... + 'YMinorTick', 'off', ... + 'YGrid', 'off', ... + 'XGrid', 'off', ... + 'XColor', 'k', ... + 'YColor', 'k', ... + 'GridLineStyle', ':', ... + 'GridColor', 'k', ... + 'GridAlpha', 0.25, ... + 'LineWidth', 1, ... + 'FontName', 'Helvetica', ... + 'Fontsize', 14); + + ylabel('\cfz [N]'); +end diff --git a/utils/save2tikz.m b/utils/save2tikz.m new file mode 100644 index 0000000000000000000000000000000000000000..5f5bcc9f8e30deacaac9c9d683713c4577dc449f --- /dev/null +++ b/utils/save2tikz.m @@ -0,0 +1,30 @@ +function save2tikz(filename, tikzFontSize) + % SAVE2TIKZ Saves the current figure to tikz. + % This function defines sane defaults to use for saving figures in Tikz format. + % Todo + + % ---------------------------------------------------------------------------------------------- + % (c) Copyright 2022 University of Liege + % Author: Thomas Lambert <t.lambert@uliege.be> + % ULiege - Aeroelasticity and Experimental Aerodynamics + % MIT License + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + set(gcf, 'PaperPositionMode', 'auto'); + + % Tikz options + if nargin < 2 + tikzFontSize = '\normalsize'; + end + + extraTikzOptions = [ ... + 'xlabel style={font=', tikzFontSize, '},'... + 'ylabel style={font=', tikzFontSize, '},'... + 'zlabel style={font=', tikzFontSize, '}' ... + ]; + + matlab2tikz(filename, ... + 'width', '\fwidth', ... % This allows us to edit the width in latex easily + 'extraAxisOptions', extraTikzOptions, ... + 'showinfo', false); +end