Course:GEOB503/Useful Functions

From UBC Wiki

GEOB 103

Useful Functions in Matlab

unique

This is a brilliant little function that picks out the unique values from a list where the same value is repeated a number of times. Very useful, especially for time series.

horzcat & vertcat

These functions take vectors and matrices and glue them together horizontally (horzcat), in which case all inputs must have the same number of rows, or vertically (vertcat) in which the inputs must all have the same number of columns

C = textscan(fid...)

This is a very powerful way of reading in data. The syntax is a bit arcane, but once you have it running, it is really unbeatable and will allow you to import just about anything.

N = zeros(size(datayears))

This function is used to generate blank matrices with zeros in all cells. The function ones does the same thing, but fills the cells with 1's

msgbox

This function generates a graphical user interface displaying a message.

semilogx

This is a version of the plot command that automatically generates log axes. It is similar to loglog and semilogy commands.