1 / 43

Matlab Training Session 1: Introduction to Matlab for Graduate Research

Matlab Training Session 1: Introduction to Matlab for Graduate Research. Non-Accredited Matlab Tutorial Sessions for beginner to intermediate level users

lilly
Download Presentation

Matlab Training Session 1: Introduction to Matlab for Graduate Research

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 Training Session 1:Introduction to Matlab for Graduate Research

  2. Non-Accredited Matlab Tutorial Sessions for beginner to intermediate level users • Beginner SessionsSession Dates: January 13, 2009 – February 4, 2009 Session times:  Tuesday and Wednesday 3:00pm-5:00pmSession Location: Bracken Library Computer Lab • Intermediate SessionSession Dates: February 10, 2009 – March 4, 2009 Session times:  Tuesday and Wednesday 3:00pm-5:00pmSession Location: Bracken Library Computer Lab Instructors: Robert Marino rmarino@biomed.queensu.ca, (Beginner Sessions) Andrew Pruszynski 4jap1@qlink.queensu.ca (Intermediate Sessions) Course Website: http://www.queensu.ca/neurosci/matlab.php

  3. Non-Accredited Matlab Tutorial Sessions for beginner to intermediate level users Purpose: To teach essential skills necessary for the acquisition, analysis, and graphical display of research data

  4. Non-Accredited Matlab Tutorial Sessions for beginner to intermediate level users Purpose: To teach essential skills necessary for the acquisition, analysis, and graphical display of research data Promote Self Sufficiency and Independence

  5. Course Outline Each weekly session will independently cover a new and progressively more advanced Matlab topic Weeks: • Introduction to Matlab and its Interface • Fundamentals (Operators) • Fundamentals (Flow) • Importing Data • Functions and M-Files • Plotting (2D and 3D) • Statistical Tools in Matlab • Analysis and Data Structures

  6. Week 1 Lecture Outline An Introduction to Matlab and its Interface A. Why Matlab? Some Common Uses for Matlab in Research

  7. Week 1 Lecture Outline An Introduction to Matlab and its Interface A. Why Matlab? Some Common Uses for Matlab in Research B. Understanding the Matlab Environment: • Navigating the Matlab Desktop • Commonly used Toolbox Components • Executing Commands • Help and Documentation

  8. Week 1 Lecture Outline An Introduction to Matlab and its Interface A. Why Matlab? Some Common Uses for Matlab in Research B. Understanding the Matlab Environment: • Navigating the Matlab Desktop • Commonly used Toolbox Components • Executing Commands • Help and Documentation C. Using Matlab: • Matrices, Scalars and Arrays • Useful Commands • Searching and Indexing • Saving and Reloading Work

  9. Week 1 Lecture Outline An Introduction to Matlab and its Interface A. Why Matlab? Some Common Uses for Matlab in Research B. Understanding the Matlab Environment: • Navigating the Matlab Desktop • Commonly used Toolbox Components • Executing Commands • Help and Documentation C. Using Matlab: • Matrices, Scalars and Arrays • Useful Commands • Searching and Indexing • Saving and Reloading Work D. Exercises

  10. Why Matlab? • Matrix Labratory • Created in late 1970’s • Intended for used in courses in matrix theory, linear algebra and numerical analysis

  11. Why Matlab? • Matrix Labratory • Created in late 1970’s • Intended for used in courses in matrix theory, linear algebra and numerical analysis • Currently has grown into an interactive system and high level programming language for general scientific and technical computation

  12. Why Matlab? Common Uses for Matlab in Research • Data Acquisition • Multi-platform, Multi Format data importing • Analysis Tools (Existing,Custom) • Statistics • Graphing • Modeling

  13. Why Matlab? Data Acquisition • A framework for bringing live, measured data into MATLAB using PC-compatible, plug-in data acquisition hardware

  14. Why Matlab? Multi-platform, Multi Format data importing • Data can be loaded into Matlab from almost any format and platform • Binary data files (eg. REX, PLEXON etc.) • Ascii Text (eg. Eyelink I, II) • Analog/Digital Data files PC 100101010 UNIX Subject 1 143 Subject 2 982 Subject 3 87 …

  15. Why Matlab? Analysis Tools • A Considerable library of analysis tools exist for data analysis • Provides a framework for the design, creation, and implementation of any custom analysis tool imaginable

  16. Why Matlab? Statistical Analysis • A considerable variety of statistical tests available including: • TTEST • Mann-Whitney Test • Rank Sum Test • ANOVAs • Linear Regressions • Curve Fitting

  17. Why Matlab? Graphing • A Comprehensive array of plotting options available from 2 to 4 dimensions • Full control of formatting, axes, and other visual representational elements

  18. Why Matlab? Modeling • Models of complex dynamic system interactions can be designed to test experimental data

  19. Understanding the Matlab Environment: • Navigating the Matlab Desktop

  20. Understanding the Matlab Environment: • Navigating the Matlab Desktop • Commonly Used Toolboxes

  21. Understanding the Matlab Environment: • Navigating the Matlab Desktop • Commonly Used Toolboxes • Executing Commands • Basic Calculation Operators: • + Addition • - Subtraction • * Multiplication • / Division • ^ Exponentiation

  22. Using Matlab • Solving equations using variables • Expression language • Expressions typed by the user are interpreted and evaluated by the Matlab system • Variables are names used to store values • Variable names allow stored values to be retrieved for calculations or permanently saved • Variable = Expression • Or • Expression • **Variable Names are Case Sensitive!

  23. Using Matlab • Solving equations using variables • Expression language • Expressions typed by the user are interpreted and evaluated by the Matlab system • Variables are names used to store values • Variable names allow stored values to be retrieved for calculations or permanently saved • Variable = Expression • Or • Expression • **Variable Names are Case Sensitive! >> x * y Ans = 12 >> x / y Ans = 3 >> x ^ y Ans = 36 >> x = 6 x = 6 >> y = 2 y = 2 >> x + y Ans = 8

  24. Using Matlab • Working with Matrices • Matlab works with essentially only one kind of object, a rectangular numerical matrix • A matrix is a collection of numerical values that are organized into a specific configuration of rows and columns. • The number of rows and columns can be any number • Example • 3 rows and 4 columns define a 3 x 4 matrix having 12 elements

  25. Using Matlab • Working with Matrices • Matlab works with essentially only one kind of object, a rectangular numerical matrix • A matrix is a collection of numerical values that are organized into a specific configuration of rows and columns. • The number of rows and columns can be any number • Example • 3 rows and 4 columns define a 3 x 4 matrix having 12 elements • A scalar is a single number and is represented by a 1 x 1 matrix in matlab. • A vector is a one dimensional array of numbers and is represented by an n x 1 column vector or a 1 x n row vector of n elements

  26. Using Matlab Working with Matrices c = 5.66 or c = [5.66] c is a scalar or a 1 x 1 matrix 

  27. Using Matlab Working with Matrices c = 5.66 or c = [5.66] c is a scalar or a 1 x 1 matrix  x = [ 3.5, 33.22, 24.5 ] x is a row vector or a 1 x 3 matrix 

  28. Using Matlab Working with Matrices c = 5.66 or c = [5.66] c is a scalar or a 1 x 1 matrix  x = [ 3.5, 33.22, 24.5 ] x is a row vector or a 1 x 3 matrix  x1 = [ 2 5 3 -1] x1 is column vector or a 4 x 1 matrix

  29. Using Matlab Working with Matrices c = 5.66 or c = [5.66] c is a scalar or a 1 x 1 matrix  x = [ 3.5, 33.22, 24.5 ] x is a row vector or a 1 x 3 matrix  x1 = [ 2 5 3 -1] x1 is column vector or a 4 x 1 matrix A = [ 1 2 4 2 -2 2 0 3 5 5 4 9 ]A is a 4 x 3 matrix

  30. Using Matlab • Working with Matrices • Spaces, commas, and semicolons are used to separate elements of a matrix

  31. Using Matlab • Working with Matrices • Spaces, commas, and semicolons are used to separate elements of a matrix • Spaces or commas separate elements of a row • [1 2 3 4] or [1,2,3,4]

  32. Using Matlab • Working with Matrices • Spaces, commas, and semicolons are used to separate elements of a matrix • Spaces or commas separate elements of a row • [1 2 3 4] or [1,2,3,4] • Semicolons separate columns • [1,2,3,4;5,6,7,8;9,8,7,6] = [1 2 3 4 • 5 6 7 8 • 9 8 7 6]

  33. Using Matlab • Indexing Matrices • A m x n matrix is defined by the number of m rows and number of n columns • An individual element of a matrix can be specified with the notation A(i,j) or Ai,j for the generalized element, or by A(4,1)=5 for a specific element.

  34. Using Matlab • Indexing Matrices • A m x n matrix is defined by the number of m rows and number of n columns • An individual element of a matrix can be specified with the notation A(i,j) or Ai,j for the generalized element, or by A(4,1)=5 for a specific element. • Example: • >> A = [1 2 4 5;6 3 8 2] A is a 4 x 2 matrix • >> A(1,2) • Ans 6 • The colon operator can be used to index a range of elements • >> A(1:3,2) • Ans 1 2 4

  35. Using Matlab • Indexing Matrices • Specific elements of any matrix can be overwritten using the matrix index • Example: • A = [1 2 4 5 • 6 3 8 2] • >> A(1,2) = 9 • Ans • A = [1 2 4 5 • 9 3 8 2]

  36. Using Matlab • Matrix Shortcuts • The ones and zeros functions can be used to create any m x n matrices composed entirely of ones or zeros • Example • a = ones(2,3) • a = [1 1 • 1 1 • 1 1] b = zeros(1,5) b = [0 0 0 0 0]

  37. Using Matlab • Data Types and Formats • The semicolon operator determines whether the result of an expression is displayed • who lists all of the variables in your matlab workspace • whos list the variables and describes their matrix size

  38. Using Matlab • Saving your Work • To save data to a *.mat file: • Typing ‘save filename’ at the >> prompt and the file ‘filename.mat’ will be saved to the working directory • Select Save from the file pull down menu • To reload a *.mat file • 1. Type ‘load filename’ at the >> prompt to load ‘filename.mat’ • (ensure the filename is located in the current working directory) • 2. Select Open from the file pull down menu and manually find the datafile

  39. Getting Help • Help and Documentation • Digital • Updated online help from the Matlab Mathworks website: • www.mathworks.com/access/helpdesk/help/techdoc/matlab.html • Matlab command prompt function lookup • Built in Demo’s • Websites • Hard Copy • Books, Guides, Reference • The Student Edition of Matlab pub. Mathworks Inc.

  40. Exercises Enter the following Matrices in matlab using spaces, commas, and semicolons to separate rows and columns: A = B = D = D = C = E = a 5 x 9 matrix of 1’s

  41. Exercises Use the who and whos functions to confirm all of the variables and matrices in the work space are present and correct A = B = D = D = C = E = a 5 x 9 matrix of 1’s

  42. Exercises Change the following elements in each matrix: 76 76 0 A = B = 0 D = 76 0 D = C = 76 E = a 5 x 9 matrix of 1’s 76

More Related