Skip to content

Instantly share code, notes, and snippets.

@adamjgnoel
Created September 16, 2016 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamjgnoel/987e7f668bad5a44d3cf99d0dd6e0734 to your computer and use it in GitHub Desktop.
Save adamjgnoel/987e7f668bad5a44d3cf99d0dd6e0734 to your computer and use it in GitHub Desktop.
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