Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
clear;
numPlotPoints = 50;
x = 1e-2:1e-2:100;
% Smooth curves
y1 = exp(-x);
y2 = 1-exp(-x);
% Noisy curves
n = length(x);
z1 = y1.*(1+0.005*randn(1,n));
z2 = y2.*(1+0.005*randn(1,n));
plotInd = unique(floor(logspace(0, log10(n), numPlotPoints)));
% My axes properties
axesProp.XScale = 'log';
hAxes = 0;
% Create 'Ghost curves' for legend
curveProp.Marker = 'none';
[~, hAxes, ~] = my_plot_function(hAxes, NaN, NaN,[],axesProp,curveProp,...
'Time [s]', 'Exponential Observation');
curveProp.Marker = 'o';
curveProp.LineStyle = 'none';
[~, hAxes, ~] = my_plot_function(hAxes, NaN, NaN,[],axesProp,curveProp,...
'Time [s]', 'Exponential Observation');
hLegend = legend(hAxes, 'Analytical', 'Simulation');
set(hLegend, 'Interpreter', 'latex');
% Add smooth curves
curveProp.Marker = 'none';
curveProp.LineStyle = '-';
[~, hAxes, ~] = my_plot_function(hAxes, x(plotInd),y1(plotInd),[],[],curveProp,...
[], []);
curveProp.Color = [0 0 1];
[~, hAxes, ~] = my_plot_function(hAxes, x(plotInd),y2(plotInd),[],[],curveProp, [], []);
% Add noisy curves
curveProp.LineStyle = 'none';
curveProp.Marker = 'o';
curveProp.Color = [0 0.6 0];
[~, hAxes, ~] = my_plot_function(hAxes, x(plotInd),z1(plotInd),[],[],curveProp, [], []);
curveProp.Color = [1 0 0];
[~, hAxes, ~] = my_plot_function(hAxes, x(plotInd),z2(plotInd),[],[],curveProp, [], []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.