Matlab functions

A miscellaneous collection of useful generic custom-written Matlab functions. See my DP tools page for more specific dynamic programming functional units.

DYNAMIC PROGRAMMING

Optdec.m - finds the largest values and associated indices from a multidimensional array of values. It is really handy for when an array has been created in a dynamic programming function corresponding to the right-hand-side of the DP equation, where each dimension is either a state variable or a decision variable.

OptdecWithError.m - finds the largest values and associated indices from a multidimensional array of values. It is really handy for when an array has been created in a dynamic programming function corresponding to the right-hand-side of the DP equation, where each dimension is either a state variable or a decision variable.

indexfromarray.m - returns the values from an array at the coordinates provided in other input variables. I use it for fetching the optimal decisions during forward simulation that were found in the backwards iteration of a DP function.

OPTIMISATION

changedetect.m - finds the indices and direction of changes in a vector containing two values.

findmaxasym.m - finds the indices and direction of changes in a vector containing two values.

peakwalks.m - finds the indices and direction of changes in a vector containing two values.

SIMULATIONS

generation.m - finds the indices and direction of changes in a vector containing two values.

jiggle.m - finds the indices and direction of changes in a vector containing two values.

PLOTTING

niceplot.m - Draws a single panel line plot with automatic labelling of each line and with user-determined tick positions.

phasediagram.m - Takes an 2D array of values and plots a phase diagram, indicating the 2D shifts in state with scalable arrows.

subplotarrange.m - Takes a number of panels and returns the best height and width to display the panels, along with alphabetical labels for each panel, and vectors of zeros and ones corresponding to which panels should have axes labels and tick labels. Handy for when you want flexibility in the number of panels to be displayed.

zoneplot.m - Takes a 2D array of integers and plots it as zones of the same values. Handy for plotting in what parts of space different strategies are best.