Skip to content

A collection of useful MATLAB routines I've written or modified. Some of these are evoked by MATLAB scripts or functions in other repositories

License

Notifications You must be signed in to change notification settings

NeuroLaunch/MATLAB_Misc

Repository files navigation

MATLAB General Utility Functions

A collection of useful MATLAB routines I've written and collected over the years, many called by programs in other repositories. The code can easily be translated to the Python numpy module (keeping in mind that MATLAB indexing starts at 1).

M-file Description / Example
getclosest Find the closest elements, by absolute value, of one vector to another; returns an index
  actual = [0 10 20 30 40 50]; desired = [-2 0 9 11 24 26 165]; output = [1 1 2 2 3 4 6]
spaceout Expand vector of integers (such as representing an index) or booleans forward and backwards by integer 'space'
  input = [34 35 36 90]; space = 2; output = [32 33 34 35 36 37 38 88 89 90 91 92]
cleanmean Calculate the mean and std of a vector or array, excluding values outside a set range
 
getstd Get std. deviation of an array, excluding points defined by an index (invoking spaceout.m)
 
readExcel Generic function to read in columns from an Excel spread sheet
 
lookforfiles Get the name of all files from a directory matching a desired pattern
 
compare_structures Determine whether two structures have matching fields containing identical values
 
struct2array Combine N-length numeric values from a field in an M-length structure to a single M*N array
 
zerocell Create an M-dimensional cell array that contains N-dimensional all-zero matrices
 
augmatrix Extend the rows of a square matrix using linear interpolation or simple mirroring around the diagonal pivot
 
draggable Third-party function to allow graphic objects to be dragged; I added a callback routine, now available in a more on the Mathworks File Exchange, to facilitate the manual creation of boxes around data points in a scatter plot (e.g. for semi-supervised classification of neural spike waveforms)
 
findjobj Third-party function to find a java object within a Matlab graphics object, specified by its handle
 
sgfilter Third-party function to implement a smoothing FIR filter via local least-squares fitting
 
xticklabel_rotate Third-party function to easily rotate x-axis labels by a specified number of degrees
 
readExcel Read columns from an Excel spread sheet from a specified page using instructions for column/row ranges; output is a 1x1 structure, with a different field for each output vector or 2-D matrix
 
tryload Load specific variables (wildcard "*" accepted) into a structure or workspace
 
make_vararray Transform scalars or vectors to an array of permutations of their elements, using the MATLAB function NDGRID
  var1 = [ 0 30 60 90 ], var2 = [ 100 200 ]; output = [ 0 30 60 90 0 30 60 90 ; 100 100 100 100 200 200 200 200 ]
useful A random assortment of code snippets I've found useful for reference
 

About

A collection of useful MATLAB routines I've written or modified. Some of these are evoked by MATLAB scripts or functions in other repositories

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages