nargchk is used almost exclusively in one way:
error(nargchk(minargs, maxargs, nargin, 'struct'));
The third and fourth arguments are always the same, and you always wrap it in an error call.
This stupidly simple function saves you typing, and prettifies your code by wrapping the above line into something more readable, namely
Having your m-files documented in a standard way (or at all!) is very useful for sharing code between projects, and between people. The trouble is, clicking File -> New -> Function doesn't give you much to go on, and it is very easy to be...
Two files are included:
CALCNBINS, which calculates the "ideal" number of bins to use in a histogram, using three possible methods. (Freedman-Diaconis', Scott's and Sturges' methods.)
HISTX is a wrapper for Matlab's own...
In order to set default values for variables, I find the start of my functions littered with
if nargin < 1 || isempty(x)
x = 1;
if nargin < 2 || isempty(y)
y = 3;
The stats toolbox provides a function to calculate the geometric mean of an array, but a function for the geometric standard deviation is oddly missing.
Here is a function to fill that void, with no toolbox required.
GetPreference and SetPreference provide a programmatic alternative to the Preferences dialog (File -> Preferences).
Use these to automatically configure your version of MATLAB to how you like it. (Save on setup time with each new...
A set of utilities to programmatically manipulate shortcuts (including toolbar shortcuts and help browser favourites).
AddShortcut adds a shortcut to the specified group, which by default is the toolbar, e.g.
ISMONOTONIC(X) returns a boolean value indicating whether or not a vector is monotonic.
By default, ISMONOTONIC returns true for non-strictly monotonic vectors,
and both monotonic increasing and monotonic decreasing vectors. For