Lund University                                                                                                                      Department of Physics
Division of Experimental High Energy Physics
Research         Staff         Address         Education         Events         Links


Useful Matlab functions

Here is a short list of MatLab function that you can use for the analysis. There are other ways to do it, and these descriptions are not complete... Just see them as a starting point.
  • M = dlmread('filename')
    allows to read a file and put it in a matrix M.
  • M(:,1) is a vector containing the first column of the matrix M.
  • f = @(param) func(param)
    allows you to define a function f with the vector of parameters param.
    e.g. parabola = @(V) V(1)*V(1)+V(2)*V(2)
  • sum( f(V(:)) )
    Sums the function f applied to each element of the vector V
    e.g. sum( parabola(M(:,1), M(:,2)) ) will give the sum of the squares of the elements of the first and second columns of the matrix M.
  • fitparams = fminsearch(f,init_param)
    will search the parameters which will minimise the function f, with starting parameters init_param.
    e.g. fminsearch(parabola,[1 1]); should give [0 0], which correspond to the bottom of the parabola.
  • plot(x,y)
    will plot x vs y (arrays of values).
  • axis([xmin xmax ymin ymax])
    Sets the range of your graph's axes.
  • xlabel("foo"), ylabel("bar")
    Gives a title to the x and y axes of your graph.


    Last Updated: