Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matlab Training Session 1:

Similar presentations


Presentation on theme: "Matlab Training Session 1:"— Presentation transcript:

1 Matlab Training Session 1:
Introduction to Matlab for Beginner Course Website:

2 Course Outline Each weekly session will independently cover a new and progressively more advanced Matlab topic 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

3 An Introduction to Matlab and its Interface
Week 1: Lecture Outline An Introduction to Matlab and its Interface

4 B. Understanding the Matlab Environment:
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

5 Why Matlab? 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

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

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

8 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 UNIX Subject 1 143 Subject 2 982 Subject 3 87 …

9 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

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

11 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

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

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

14 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 = 6 x = 6 >> y = 2 y = 2 >> x + y Ans = 8 >> x * y Ans = 12 >> x / y Ans = 3 >> x ^ y Ans = 36

15 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

16 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

17 Using Matlab Working with Matrices
c = 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 = [ ] A is a 4 x 3 matrix

18 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 [ ] or [1,2,3,4] Semicolons separate columns [1,2,3,4;5,6,7,8;9,8,7,6] = [ ]

19 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 = [ ; ] A is a 2 x 4 matrix >> A(1,2) Ans 2 The colon operator can be used to index a range of elements >> A(1, 1:3) Ans 1 2 4

20 Using Matlab Indexing Matrices
Specific elements of any matrix can be overwritten using the matrix index Example: A = [ ] >> A(2,1) = 9 Ans ]

21 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 = [ ]

22 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

23 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

24 Getting Help Help and Documentation Digital Hard Copy
Updated online help from the Matlab Mathworks website: Matlab command prompt function lookup Built in Demo’s Websites Hard Copy Books, Guides, Reference The Student Edition of Matlab pub. Mathworks Inc.

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

26 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 = E = C = D = E = a 5 x 9 matrix of 1’s

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


Download ppt "Matlab Training Session 1:"

Similar presentations


Ads by Google