ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )

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 Matlab
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
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.
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Matlab intro The Environment
MATLAB Fundamentals.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
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.
IC3003 B ASIC S CIENTIFIC C OMPUTING Lecture 1 Monday 08:30-11:30 U204a.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
How to Use MATLAB A Brief Introduction. 2 What can MATLAB do? Matrix Operations Symbolic Computations Simulations Programming 2D/3D Visualization.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Basics of MATLAB By DR. Wafaa Shabana
MAE 1202: AEROSPACE PRACTICUM An Introduction to MATLAB: Part 2 Mechanical and Aerospace Engineering Department Florida Institute of Technology Developed.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
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.
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
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.
Slide Copyright © 2009 Pearson Education, Inc. 7.3 Matrices.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Matrix Algebra Section 7.2. Review of order of matrices 2 rows, 3 columns Order is determined by: (# of rows) x (# of columns)
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
MATRICES MATRIX OPERATIONS. About Matrices  A matrix is a rectangular arrangement of numbers in rows and columns. Rows run horizontally and columns run.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
A rectangular array of numeric or algebraic quantities subject to mathematical operations. The regular formation of elements into columns and rows.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
ECE 1304 Introduction to Electrical and Computer Engineering
Matrix Operations Free powerpoints at
Introduction to Matlab
Matrix Operations.
Matrix Operations Free powerpoints at
Matrix Operations.
Matrices and Arrays.
MATLAB DENC 2533 ECADD LAB 9.
Introduction To MATLAB
Matrix Operations Free powerpoints at
EEE 244 Numerical Methods In Electrical Engineering
7.3 Matrices.
MATLAB How to use (using M-files) Double click this icon
Use of Mathematics using Technology (Maltlab)
MATLAB How to use (using M-files) Double click this icon
MATRICES MATRIX OPERATIONS.
MATLAB How to use (using M-files)
MATRICES MATRIX OPERATIONS.
244-2: MATLAB/Simulink FUNDAMENTALS
3.5 Perform Basic Matrix Operations
How to Use MATLAB A Brief Introduction.
Matlab Basics Tutorial
MATRICES MATRIX OPERATIONS.
Presentation transcript:

ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )

W HY MATLAB? The name MATLAB (matrix laboratory), is Developed by Mathworks. html While the software has progressed well beyond its original goal as a tool dedicated to performing matrix computations, it is still based on the notation of arrays and matrices. The latest version is R2013b

MATLAB is a high-level language and interactive environment that enables you to perform computationally intensive tasks. High-level language for technical computing Development environment for managing code, files, and data

Interactive tools for iterative exploration, design, and problem solving Mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, and numerical integration 2-D and 3-D graphics functions for visualizing data

M ATRICES, A RRAYS AND V ECTORS A matrix is simply a rectangular list of numbers The "size" of a matrix is given as two numbers, the first is traditionally the number of rows in the matrix while the second is the number of columns in the matrix. Matrices are usually written in tabular form contained between two large parentheses or square brackets.

Arrays/vectors: matrices with only ONE row or column Example A 2×3 ( two by three ) matrix A 1×3 row vector A 2×1 column vector

T O S TART M ATLAB Command window Single line commands, results Editor Edit scripts Workspace Store variables Current Folder Store files

T O S TART M ATLAB

Command window Only one line a time Create a new.m file File->New->Script Check the usage of ‘;’, ‘%’, ‘%’ Save and Run

P RESENT M ATRICES IN MATLAB >> a=[1 2 3; 4 5 6] Or >> a=[1, 2, 3; 4, 5, 6] Try on your own computer if you haven’t done so.

A RITHMETIC O PERATIONS Scalar operations: There are four scalar operations addition: + subtraction: - multiplication: * division: /

Example >> a=[1 2 3; 4 5 6] >> b=3*a >> b=[3 6 9; ]

Matrix Addition and Subtraction For two matrices to be added or subtracted they must be of the same size. The entries are computed by adding or subtracting the corresponding entries in the two original matrices. Example >> a=[1 2 3; 4 5 6] >> b=[2 4 6; 3 5 7] >> c=a-b c=[ ; ]

Multiplication and Division 2 different types: componentwise and conventional Recall: How to multiply matrices?

Normal multiplication: A, B, C is n by n In MATLAB >> C=A*B

Componentwise multiplication: Same problem as before, In MATLAB >> C=A.*B

F UNCTIONS AND S HORTCUTS Functions: operations that can be called in a scripts Zeros() Ones() Eye() Diag() Linspace() …

Zeros(n) to create an n by n matrix with all entries zero. Zeros(n, m) create an n by m one. Ones(n) to create an n by n matrix with all entries 1. Used as the same fashion as zeros(n) Eye(n) to create an n by n identity matrix. Diag([]) to create a diagonal matrix. Vector given shows as diagonal elements.

Two shortcuts for row vectors: 1. vector=a:n:b the vector starts with a and end with b, n is the step size Example >> t=1:0.5:3 t= If n is not given, default value is 1 >> t=1:3 t=1 2 3

2 linspace(a, b, n) to create a row matrix with n elements, start from a and end with b, with equal step size. Example: >> t=linspace(0,10,11) t=

size() inv() []’ fft() Functions can be self defined. Most functions work componentwise

S ELF - DEFINED FUNCTION File->New->Function Input arguments Output arguments Function name How to call function

H OW TO PLOT FIGURES ? Plot(x,y): 2 vector input, x will be horizontal axis and y be the vertical one. x, y must be the same size s: applicable parameters: color, plot symbol, line type used as character strings.

t=0:0.1:5 y=sin(2*pi*t) Plot(t,y)

t=0:0.001:5 y=sin(2*pi*t) Plot(t,y)

plot(t,y,'--')

plot(t,y,'g')

Legend, title and label legend(‘strings1’,’strings2’…..’location’,’orientation’) e.g legend('sin function') Title Title(‘text’) e.g title('function') Label Xlabel(‘text’) e.g xlabel('time') Similar: ylabel, zlabel

Example 1 t=0:0.001:5 x=cos(2*pi*t) y=sin(2*pi*t) plot(t,x,'g') hold on plot(t,y,'r')

Example 2 t=0:0.001:5 x=cos(2*pi*t) y=sin(2*pi*t) subplot(2,1,1) plot(t,x,'g') subplot(2,1,2) plot(t,y,'r')

HW1HW1 t = (-2:0.01:2)/1000; a1 = 500; x1 = 20 * sin(2*pi*1000*t - pi/3).* exp(-a1*t); a2 = 750; x2 = 20 * sin(2*pi*1000*t - pi/3).* exp(-a2*t); a3 = 1000; x3 = 20 * sin(2*pi*1000*t - pi/3).* exp(-a3*t); %Plot Resutls figure(1); clf; plot(t,x1,'b'); hold on plot(t,x2,'k:'); plot(t,x3,'r--'); hold off xlabel('time (sec)') ylabel('Amplitude') title('Exponentially Damped Sinusoid') axis([-2/1000 2/ ]) legend('a = 500','a = 750','a = 1000')

HW1HW1

2. semilogy(x, y, s) logarithmic (base 10) scale is used for the Y-axis. Used as the same fashion as plot. Similar: semilogx, loglog. Example:

B ASIC P ROGRAMMING S YNTAX FOR ‘for’ is used for repeating statements Example: t=0; for i=1:5 t=t+i; end Also see WHILE

IF If Conditionally execute statements. Example t=0; for i=1:5 if i>3 t=t+i; end

Q UESTIONOS