mtools by srinivas.gs
This repository contains a bunch of useful scripts and functions that make working in MATLAB much easier. All my other MATLAB repositories depend on this. Feel free to do with functions that I have written what you will. Some functions written by others are also included here, with licenses and attribution where possible.
Functions in this repository are organized into:
betadon't use this.
figure-toolsTools to make better plots. For example, prettyFig makes pretty figures.
file-toolstools for working with files on your computer. For example,
abf2kontroller, which converts AutoSpike files into kontroller compatible files.
image-toolstools to help you with working with images. For example,
saturationPlanecomputes the saturation plane from a colour image.
internet-toolsto help you work over HTTP connections.
installis my package manager that installs toolboxes from GitHub.
maths-toolsare functions for various mathematical operations. e.g.,
spearcomputes the Spearman rank correlation.
matlab-toolsMATLAB-specific tools, to work around various quirks and missing bits in MATLAB. For example, the excellent
swapswaps two variable in place.
neuro-toolstools specific to neuroscience. For example,
raster2plots a raster of spike times from two neurons.
publish-toolsThis toolset is built around MATLAB's
publishfunction. For details on what you can do with this, look at this repo.
string-toolstools to work with strings. For example,
randomString(100)spits out a 100 random characters.
time-series-toolstools to work with time series. For example,
fastFilterspeeds up convolutions using GPUs and Fourier Transforms for long time series.
General Notes on Usage
All functions here have help above the function definition, and you can get help about any file using
>> help raster2
raster2.m makes a raster plot of two different neurons. A (or B) can be either a logical matrix with 1 where a spike occurs, or long (zero padded) matrices of spike times. The time step is assumed to be 1e-4s This function is designed to be faster the the original raster created by Srinivas Gorur-Shandilya at 10:20 , 09 April 2014. Contact me at http://srinivas.gs/contact/ This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.
You can also call most functions with no arguments and it will return help, if at least one argument is required for that function. So
raster2 is the same as
The reccomended way to install this is to use my package manager (which is included in this repo):
>> urlwrite('http://srinivas.gs/install.m','install.m'); >> install sg-s/srinivas.gs_mtools
or you can install using
$ git clone https://github.com/sg-s/srinivas.gs_mtools.git
If you do the latter, make sure you get add the paths to the subfolders to your
makePDF.m and cleanPublish.m
makePDF.m is a wrapper for MATLAB's publish function that accepts a script, and makes into a PDF directly. It works by first using
publish to make a .tex file, then using
pdflatex to compile that to a PDF. Assumes you are working on a Unix machine with
This repo has a detailed workflow built around
cleanPublish.m to remove all the figures and log files after the PDF is compiled.
textbar is a text-based
waitbar replacement. Drop it into long loops:
for i = 1:34 textbar(i,34) % do some long computation end
will show you a progress bar and how many loops have evaluated. For loops that run more than a hundred times,
textbar intelligently switches to percent completed. The progress bar is erased when the loop completes.
oval is a version of
round that is meant for use in figure labels, etc.
oval returns a rounded string to an arbitrary number of digits:
>> oval(pi,2) 3.14
oval can also handle fractions, if you tell it to:
>> oval(1/7,'frac') 1/7