Skip to content

Instantly share code, notes, and snippets.

View adamjgnoel's full-sized avatar

Adam Noel adamjgnoel

View GitHub Profile
% Simple 2D Diffusion Simulation
% Created 19 May 2023 by Adam Noel
% Parameters
N = 2000; % Number of molecules
D = 1; % Diffusion coefficient [m^2/s]
dt = 1; % Time step [s]
RX = [9,11,9,11]; % Receiver
numRepeat = 10; % Number of realizations/repeats
rng(1)
% This is a working example to demonstrate use of switches to maintain multiple
% versions of a single document
%
% Uses the IEEEtran class: https://www.ctan.org/pkg/ieeetran
%
% Created 2016-10-30 by Adam Noel
% Define the switch here using "newif" and start its name with "if"
% Here, NAME_OF_SWITCH == "OneCol"
\newif\ifOneCol
clear;
numPlotPoints = 50;
x = 1e-2:1e-2:100;
% Smooth curves
y1 = exp(-x);
y2 = 1-exp(-x);
function [hFig, hAxes, hCurve] = my_plot_function(hAxes, ...
xData, yData, myFigProp, myAxesProp, myCurveProp, xStr, yStr)
% A plotting wrapper function. Designed to plot one curve per call.
%
% INPUTS
% hAxes - handle to existing axes (set to 0 to create new figure and axes)
% xData - x data to plot (set to [] to not plot)
% yData - y data to plot (set to [] to not plot)
% myFigProp - structure of figure properties to change from defaults. See
% subfunction buildFigureStruct for defaults. Ignored if hAxes == 0. Set
numPlotPoints = 50;
x = 1e-2:1e-2:100;
% Smooth curves
y1 = exp(-x);
y2 = 1-exp(-x);
% Noisy curves
% This script removes the selected lines from a figure's legend. The lines
% must be selected BEFORE calling this script
%
% Created June 6, 2014, by Adam Noel
%
function removeLegendLines()
a = findobj('Selected', 'on');
for i = 1:length(a)
hasbehavior(a(i), 'legend', false);
end
numPlotPoints = 50;
x = 1e-2:1e-2:100;
% Smooth curves
y1 = exp(-x);
y2 = 1-exp(-x);
% Noisy curves
% Plotting take 4
numPlotPoints = 50;
x = 1e-2:1e-2:100;
% Smooth curves
y1 = exp(-x);
y2 = 1-exp(-x);
% Plotting take 3
x = 1e-2:1e-2:100;
% Smooth curves
y1 = exp(-x);
y2 = 1-exp(-x);
% Noisy curves
n = length(x);
% Plotting take 2
x = 1e-2:1e-2:100;
% Smooth curves
y1 = exp(-x);
y2 = 1-exp(-x);
% Noisy curves
n = length(x);