matlab introduction

by Jonathan Harel
  1. There are
    • data stored in variables (*)
    • functions which operate on the variables(**)

      • (*) variables are usually 1. matrices, 2. cell arrays, or 3. structures.
        Here is an example "script" (set of Matlab commands in a file) showing how to create these basic data types: egcreate.m
        full list of data types (for reference)

      • (**) functions are top-level (no namespace, io.file.open etc.).
        Which functions you can call depends on your matlab "path". (that is, matlab will search for a file somewhere in a directory entered in your path which implements the function).

        Here is an example function: egfunc.m

        Also note that you can count the input arguments with "nargin", and accept a variable number of arguments using "varargin".
        Here is an example function using those two: mymessage.m

        Large sets of functions are often grouped together into "toolboxes". You don't need to do anything special to access a file from a toolbox. Sometimes - other people have posted just the function you are looking for on "matlab central"; though beginners will probably find everything they need inside Matlab's massive library or one of the standard toolboxes.


  2. Indexing (accessing some elements) of a matrix is very important in matlab.
      Here is a script showing how to index: egindex.m

  3. Finding sums, means, etc. along various dimensions of a matrix is very useful in matlab:
      Here is a script showing how to do that: eguseful.m

  4. Plotting figures is very important in matlab.
      Here is a simple example of plotting: egplot.m

  5. Here is a list of more functions you may want to use, type "help [functionname]" at the Matlab prompt to explore these.

    image processing
      imread, imwrite, imshow, imagesc, colormap, conv2, conv

    utility
      dir, system, clear, save, whos, profile

    statistics
      ttest, ttest2, kstest, kstest2, binomcdf, normcdf, normpdf


  6. Finally, you can refer to these to learn: