Skip to content
Snippets Groups Projects
Verified Commit f56ae2fa authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

feat(figures): add save figure

parent 1e157e25
No related branches found
No related tags found
No related merge requests found
......@@ -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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment