Document Sample

Matlab Training Session 1: Introduction to Matlab for Graduate Research Non-Accredited Matlab Tutorial Sessions for beginner to intermediate level users • Beginner Sessions Session Dates: January 13, 2009 – February 4, 2009 Session times: Tuesday and Wednesday 3:00pm-5:00pm Session Location: Bracken Library Computer Lab • Intermediate Session Session Dates: February 10, 2009 – March 4, 2009 Session times: Tuesday and Wednesday 3:00pm-5:00pm Session 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 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 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 Course Outline Each weekly session will independently cover a new and progressively more advanced Matlab topic Weeks: 1. Introduction to Matlab and its Interface 2. Fundamentals (Operators) 3. Fundamentals (Flow) 4. Importing Data 5. Functions and M-Files 6. Plotting (2D and 3D) 7. Statistical Tools in Matlab 8. Analysis and Data Structures Week 1 Lecture Outline An Introduction to Matlab and its Interface A. Why Matlab? Some Common Uses for Matlab in Research 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 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 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 Why Matlab? • Matrix Labratory • Created in late 1970’s • Intended for used in courses in matrix theory, linear algebra and numerical analysis 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 Why Matlab? Common Uses for Matlab in Research • Data Acquisition • Multi-platform, Multi Format data importing • Analysis Tools (Existing,Custom) • Statistics • Graphing • Modeling Why Matlab? Data Acquisition • A framework for bringing live, measured data into MATLAB using PC-compatible, plug-in data acquisition hardware 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 … 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 Why Matlab? Statistical Analysis • A considerable variety of statistical tests available including: – TTEST – Mann-Whitney Test – Rank Sum Test – ANOVAs – Linear Regressions – Curve Fitting 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 Why Matlab? Modeling • Models of complex dynamic system interactions can be designed to test experimental data Understanding the Matlab Environment: Navigating the Matlab Desktop Understanding the Matlab Environment: Navigating the Matlab Desktop Commonly Used Toolboxes Understanding the Matlab Environment: Navigating the Matlab Desktop Commonly Used Toolboxes Executing Commands Basic Calculation Operators: + Addition - Subtraction * Multiplication / Division ^ Exponentiation 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! 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 >> x = 6 >> x * y Variable = Expression x=6 Ans = 12 Or >> y = 2 >> x / y Expression y=2 Ans = 3 >> x + y >> x ^ y **Variable Names are Case Sensitive! Ans = 8 Ans = 36 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 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 Using Matlab Working with Matrices c = 5.66 or c = [5.66] c is a scalar or a 1 x 1 matrix 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 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 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 Using Matlab Working with Matrices • Spaces, commas, and semicolons are used to separate elements of a matrix 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] 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 5678 9 8 7 6] 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. 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 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] 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) b = zeros(1,5) a = [1 1 b = [0 0 0 0 0] 11 1 1] 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 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 Getting Help Help and Documentation Digital 1. Updated online help from the Matlab Mathworks website: www.mathworks.com/access/helpdesk/help/techdoc/matlab.html 3. Matlab command prompt function lookup 4. Built in Demo’s 5. Websites Hard Copy 3. Books, Guides, Reference The Student Edition of Matlab pub. Mathworks Inc. Exercises Enter the following Matrices in matlab using spaces, commas, and semicolons to separate rows and columns: 1 21 6 A = 5 17 9 B = 1 64 122 78 38 55 31 2 7 D = 65 4 8 41 166 42 22 55 28 16 2 C= D= 16 0 0 1 12 E = a 5 x 9 matrix of 1’s 160 25 65 24 19 Exercises Use the who and whos functions to confirm all of the variables and matrices in the work space are present and correct 1 21 6 A = 5 17 9 B = 1 64 122 78 38 55 31 2 7 D = 65 4 8 41 166 42 22 55 28 16 2 C= D= 16 0 0 1 12 E = a 5 x 9 matrix of 1’s 160 25 65 24 19 Exercises Change the following elements in each matrix: 1 76 6 6 A = 5 17 9 B = 1 76 122 78 38 55 64 0 31 0 7 2 D = 65 4 8 41 166 42 22 55 76 28 16 2 0 C= D= 76 16 0 0 1 12 E = a 5 x 9 matrix of 1’s 160 25 65 24 76 19

DOCUMENT INFO

Shared By:

Categories:

Tags:
how to, matlab functions, graduate school, training session, matlab m-file, the matrix, command window, digital signal processing, matlab environment, the user, training course, booking system, postgraduate training, no credit, maximum number

Stats:

views: | 42 |

posted: | 9/27/2010 |

language: | English |

pages: | 43 |

OTHER DOCS BY amu27910

How are you planning on using Docstoc?
BUSINESS
PERSONAL

By registering with docstoc.com you agree to our
privacy policy and
terms of service, and to receive content and offer notifications.

Docstoc is the premier online destination to start and grow small businesses. It hosts the best quality and widest selection of professional documents (over 20 million) and resources including expert videos, articles and productivity tools to make every small business better.

Search or Browse for any specific document or resource you need for your business. Or explore our curated resources for Starting a Business, Growing a Business or for Professional Development.

Feel free to Contact Us with any questions you might have.