Matrix Laboratory Created in late 1970’s Intended for used in courses in matrix theory, linear algebra and numerical analysis Currently has grown into.

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

Introduction to MATLAB The language of Technical Computing.
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Matrix Laboratory Created in late 1970’s Intended for used in courses in matrix theory, linear algebra and numerical analysis Currently has grown into.
Announcements Problem Set 2, handed out today, due next Tuesday. Late Homework should be turned into my office with date and time written on it. Mail problem.
Announcements Class mailing list: send to Hyoungjune Yi: Homework at the end of class. Text is on reserve in the.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Digital Image Processing Lecture3: Introduction to MATLAB.
APA6903 November 4, 2014 Presented By: Catriona Czyrnyj Content By: Giulia Mantovani and Catriona Czyrnyj Introduction to MATLAB and Matrix Review.
MATLAB Fundamentals.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
Matlab tutorial and Linear Algebra Review Today’s goals: Learn enough matlab to get started. Review some basics of Linear Algebra Essential for geometry.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Introduction to MATLAB
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Basics of MATLAB By DR. Wafaa Shabana
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Matlab for Engineers Matlab Environment Chapter 2.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
An Introduction to Programming in Matlab Emily Blumenthal
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
ECE 1304 Introduction to Electrical and Computer Engineering
Statistical Computing in MATLAB
2) Platform independent 3) Predefined functions
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
EEE 244 Numerical Methods In Electrical Engineering
StatLab Matlab Workshop
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Digital Image Processing
INTRODUCTION TO MATLAB
Matlab Training Session 2: Matrix Operations and Relational Operators
Presentation transcript:

Matrix Laboratory 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

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

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

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 Subject Subject 3 87 …

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

Statistical Analysis » A considerable variety of statistical tests available including: ˃TTEST ˃Mann-Whitney Test ˃Rank Sum Test ˃ANOVAs ˃Linear Regressions ˃Curve Fitting

Graphing » A Comprehensive array of plotting options available from 2 to 4 dimensions » Full control of formatting, axes, and other visual representational elements

Modeling » Models of complex dynamic system interactions can be designed to test experimental data

You can change the desktop arrangement to meet your needs, including resizing, moving, and closing tools.

1 2

» Ordered set of numbers: (1,2,3,4) » Example: (x,y,z) coordinates of pt in space.

Vector Addition v w V+w

Scalar Product v av

» sum » max, min, mean, sort, … » Pointwise:.^

Inner (dot) Product v w  The inner product is a SCALAR!

Matrices Sum: A and B must have the same dimensions

Matrices Product: A and B must have compatible dimensions Identity Matrix:

Matrices Transpose: If A is symmetric

Matrices Determinant: A must be square ( n = m ) The area of the parallelogram is the absolute value of the determinant of the matrix formed by the vectors representing the parallelogram's sides. n = m = 2 n = m = 3 The volume of this Parallelepiped is the absolute value of the determinant of the matrix formed by the rows r1, r2, and r3.Parallelepiped r1 r2 r3

Matrices Inverse: A must be square

2D Translation t P P’P’P’P’

2D Translation Equation P x y tx ty P’P’P’P’ t

2D Translation using Matrices P x y tx ty P’P’P’P’ t tP

Scaling P P’P’P’P’

Scaling Equation P x y s.x P’P’P’P’ s.y

Stretching Equation P x y Sx.x P’P’P’P’ Sy.y

Rotation P P’P’P’P’

Rotation Equations Counter-clockwise rotation by an angle  P x y’y’y’y’ P’P’P’P’  x’x’x’x’ y

Properties of rotation matrixes R is a rotation matrix and it must satisfy the following constraints:

P x y y’y’ x’x’

Navigating the Matlab Desktop Commonly Used Toolboxes

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 When MATLAB encounters a new variable name, it automatically creates the variable and allocates the appropriate amount of storage. Variable = Expression **Variable Names are Case Sensitive! Ex. «a» and «A» are two different variables

Solving equations using variables Variable = Expression >> x = 6 x = 6 >> y = 2 y = 2 >> x + y ans = 8 >> x - y ans = 4 >> x * y ans = 12 >> x / y ans = 3 >> x ^ y ans = 36 Basic Calculation Operators: + Addition -Subtraction Multiplication / Division ^ Exponentiation Reserved variables ! They are special names used to indicate either a specific number (e.g. pi, inf, eps, …), a keyword (e.g. char, double, …), or the result of an expression (ans). By default they have a specific meaning or value, if you assign a new expression to these names, you cannot use the default reserved variable anymore during the current session of Matlab.

Working with Matrices Matlab works with rectangular numerical matrixes 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

Working with Matrices Matlab works with rectangular numerical matrixes 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

Working with Matrices c = 5.66 or c = [5.66] c is a scalar or a 1 x 1 matrix

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

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 = [ ] x1 is column vector or a 4 x 1 matrix

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 = [ ] x1 is column vector or a 4 x 1 matrix A = [ ] A is a 4 x 3 matrix

Working with Matrices Spaces, commas, and semicolons are used to separate elements of a matrix

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]

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 A = [1,2,3,4;5,6,7,8;9,8,7,6] = [ ] Colon operator identifies a range of values: B = [1:4 ; 5:8 ; 9,8,7,6 ] = A

Working with Matrices Colon operator identifies a range of values: [ 1 : 3 ] = [ 1, 2, 3] [ 1 : 2: 9 ] = [ 1, 3, 5, 7, 9] [ 5 : -1: 1 ] = [ 5, 3, 1] B = [1:4 ; 5:8 ; 9,8,7,6 ] = A A = [1,2,3,4;5,6,7,8;9,8,7,6] = [ ] start jump end

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(4,1)=5

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(4,1)=5 Example: >> A = [ ; ] 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

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

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 = [ ] (!) if you need to understand more about how to use these functions, go to the HELP! b = zeros(1,5) b = [ ]

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

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 Automatically, all the variables in the workspace will be stored in the same mat-file named filename.mat. To reload a *.mat file Type ‘load filename’ at the >> prompt to load ‘filename.mat’ (ensure the filename is located in the current working directory) Select Open from the file pull down menu and manually find the data file (!) Again…to see all the options that are offered for a function, type doc namefunction

Using functions Matlab has a wide variety of toolboxes, whithin each toolbox you can find several type of functions specific for that topic. Some functions are generic and you can find them in the MATLAB TOOLBOX. RESULT: more or less, you can find any type of function you need. For a list of the elementary mathematical functions, type help elfun For a list of more advanced mathematical and matrix functions, type help specfun help elmat You can just create an elaboration by using the available functions, or you can create your own function (see after).

Basic plotting commands FunctionDescription plot Graph 2-D data plot3 Graph 3-D data plot plot3 Help – Search – type plot and obtain the following explanation! plot(Y) plots the columns of Y versus the index of each value when Y is a real number. plot(X1,Y1,...,Xn,Yn) plots each vector Yn versus vector Xn on the same axes. If one of Yn or Xn is a matrix and the other is a vector, plots the vector versus the matrix row or column with a matching dimension to the vector. For example, plot a sinusoidal curve: » t = 0:1/100:1; » y = sin(2*pi*t); » plot(t,y); More advanced! plot3(t,t,y); grid on xlabel x ylabel y zlabel z B=repmat(y,length(t),1); mesh(t,t,B); Frequency of the sinusoidal curve

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

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

Change the following elements in each matrix: Now save all the variables in the workspace in a mat-file named myvar. A = B = C = D =

Create a variable named S, which contains two cycles of a sinusoidal curve of frequency 2Hz and resolution pi/10. Plot S in a two dimensional graph. Try to use the documentation to change from the solid blue line, to a dashed red line To modify these parameters you need to add a third option to the plot command. Prompt plot(t,y, ‘options’). Instead of using the word options, use the symbols that indicate the type and the color of the line click on the LineSpec link on the plot page documentation to see which are the symbols for the dashed line and for the red.LineSpec

» What happens if I have to close Matlab because it’s time to go home??? ˃I lose all the work I did in the Command Window! ˃I lose all the variables I created during the current session of work.

» I can write the list of command, functions and variables in a new Script and then save it as a file.m » When I need to run again that list of commands I reopen the stored file.m and I can continue my work!

» Smoothing data using low pass filters » Normalizing (interpolating) data

» Smoothing data using low pass filters » Ex EMG signals Normalized for the average Rectify the signal (absolute value) Low pass filter EMG_m = mean( EMG ); EMG_n = EMG – EMG_m; EMG_r = abs( EMG_n ); [B,A] = butter(4,10/500); Z = filter( B, A, EMG_r); Work flowMatlab functions (!) Look at myemg.m in the folder

» Normalizing (interpolating) data » Ex. Express the gait signal in percentange of gait Cut the signal from FS1 to FS2 Interpolate the signal in 101 points to express it in percentage of gait cycle y_cut = Hip_FEangle(FS1:FS2) x_base_norm = linspace(0,length(y_cut),n_norm) y_norm = spline(x_base_current, y_cut, x_base_norm) Work flowMatlab functions (!) Look at mygait.m in the folder

Normalize from FS1 to FS2 in gait percentage the two signals relative to the Flexion/Extension angle at the hip joint. The variables stored in the mat-file hip_gait_data are relative to a patient A, and from hip_gait_data2 we have data from patient B. Once that both signals are normalized, plot them together in the same figure and with two different colors. Compute the Range of Motion for both signals (after normalization). Use the max and min functions to compute ROM.