1 / 7

MATLAB: An introduction

MATLAB: An introduction. Markus Bauer, UCL Institute of Cognitive Neuroscience University College London (previous version:Christian Ruff) m.bauer@fil.ion.ucl.ac.uk. Course overview. Autumn 2009: Using MATLAB for data analysis and visualisation Session 1: Basics of MATLAB / Programming

norris
Download Presentation

MATLAB: An introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MATLAB: An introduction Markus Bauer, UCL Institute of Cognitive Neuroscience University College London (previous version:Christian Ruff) m.bauer@fil.ion.ucl.ac.uk

  2. Course overview • Autumn 2009: Using MATLAB for data analysis and visualisation • Session 1: Basics of MATLAB / Programming • Session 2: Basics of MATLAB / Programming • Session 3: Handling and Importing of data & analysis • Session 4: Visualization in MATLAB • Session 5: Tips and tricks, questions and answers • Spring 2010: Using MATLAB to run experiments and collect data • Summer 2010: Advanced experimental and data analysis procedures  All materials online at http://www.icn.ucl.ac.uk/courses/MATLAB-Tutorials/index.htm

  3. What is MATLAB? • “MATrix LABoratory”, a high-level programming language / computing environment • Enables efficient programming of mathematical operations, in particular for matrix-operations • Similar to programming languages as ‘C’, but easier to use (variable definitions etc) • Advanced visualization tools --> Graphs and plotting data • Many specialised toolboxes available (e.g., statistics; image processing, etc.) + code for specific scientific purposes freely available on the internet (e.g., COGENT, SPM) • Transparent way of analysing data -> full access to data on all levels (no ‘black box’), easy to modify / build up on existing tools • Can make GUI based software environments • Disadvantages: • It is expensive (but see Octave) • It can be slow (can partially be compensated by using MEX functions, compiled)

  4. How do I get started? • http://www.mathworks.com • http://www.gnu.org/software/octave/ (free software) • Excellent documentation and tutorial (both online and in pdf form) at http://www.mathworks.com/support/ or by typing help or doc in MATLAB • Other MATLAB tutorials on the web: • http://www.icn.ucl.ac.uk/webspace/users/ahamilton/matlab.htm • http://www.mrc-cbu.cam.ac.uk/Imaging/Common/matlab.shtml • http://www.indiana.edu/~statmath/math/matlab/ • A good book: “Mastering Matlab” by Hanselmann and Littlefield • Lots of functions at http://www.mathworks.com/matlabcentral/

  5. Basics of MATLAB • - matlab windows - desktop - command window, history and workspace • Show the matlab command window: • Can use as a calculator, or to ‘interactively’ enter commands • Show history function and the tab • Where are functions - path definition and the startup file • Matlab functions and scripts: = programs • Matlab editor: a text editor • Essentials of programming: • Variables and arrays: numerical variables (integer and double), strings / string arrays • Cell arrays, structures • - built in functions (e.g. fprintf, open, save etc) • Operators: + - * / ^ logical operators: & | ~ others: () [] {} , ; : • Conditional statements : if ... elseif ... end • Loops: • For ((to)) end loop • While (conditional statement) end loop • Distinction: script and function

  6. Demo: Functions • Functions: function [output1,output2,…] = myfun(input1, input2,…) • Functions: • Input needs to be defined in command, output not • Function workspace: a separate module of the workspace • contains inputs to functions, transformation variables, and outputs from function • These variables are not visible from the global workspace • Functions can call other functions and contain subfunctions • Commands without semicolon are visible in command window • Graphical output is visible

  7. Demo: Functions in MATLAB • MATLAB – just a collection of functions: • Built-in functions cannot be edited but have an .m-file (for help) • Add-on functions are just an ordinary .m file that you can see/edit/add • How MATLAB finds a function: • Embedded in the function as subfunction • Built-in functions • Local directory • Path in descending order • Add functions to directory outside of the MATLAB toolbox (e.g., ‘work’ – otherwise MATLAB might overwrite them when re-installed • Dependency report

More Related