Introduction to MATLAB ES 156 Signals and Systems 2008 Harvard SEAS.

Slides:



Advertisements
Similar presentations
Tutorial on Matlab and OpenCV Rui Ma TA of CMPT 414 May 14, 2013 Office hours: Fridays 11:00-12:00, CSIL TA Office 1 (ASB 9838)
Advertisements

Introduction to MATLAB The language of Technical Computing.
Introduction to Matlab
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.
MATLAB - Basics Centro de Informática Universidade Federal de Pernambuco Aprendizagem de Máquina – IN1102 Arley Ristar –
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 3.
Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization.
Introduction to MATLAB Simon O’Keefe Non-Standard Computation Group
Introduction to MATLAB ES 156 Signals and Systems 2007 Harvard SEAS Prepared by Jiajun Gu.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Matlab intro The Environment
Digital Image Processing Lecture3: Introduction to MATLAB.
EPSII 59:006 Spring Outline Managing Your Session File Usage  Saving Workspace  Loading Data Files  Creating M-files More on Matrices Review.
MATLAB Fundamentals.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
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.
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,
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
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.
Array Addition  Two arrays can be added if and only if both arrays have exactly the same dimensions.  Assuming the dimension requirement is satisfied,
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
CMPS 1371 Introduction to Computing for Engineers MATRICES.
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
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation TexPoint fonts used in EMF. Read.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction MATLAB stands for MATrix LABoratory.  Basics  Matrix Manipulations  MATLAB Programming  Graphics  Image types  Image Processing  Useful.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
Introduction to MATLAB Session 1 Simopekka Vänskä, THL 2010.
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
A string is an array of characters Strings have many uses in MATLAB Display text output Specify formatting for plots Input arguments for some functions.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Sept. 26, 2005 Lecture 6 - By Paul Lin 1 CPET 190 Lecture 6 Problem Solving with MATLAB
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Spring 2016 Statics - TAM 210 & TAM 211 Discussion 1 - Intro to Matlab 1.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
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.
NoViC, Dept. of Mechanical Eng Acoustics Lab., NoViC 1. Download Matlab 2.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
MATLAB: How do you work with data to solve problems?
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to MATLAB
Introduction to MATLAB
응용 전산 및 실습 MATLAB – Chapter 3 행렬연산
Lecture 25.
TexPoint fonts used in EMF.
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Digital Image Processing using MATLAB
Lecture 2 Introduction to MATLAB
How to Use MATLAB A Brief Introduction.
MATLAB stands for MATrix LABoratory.
Presentation transcript:

Introduction to MATLAB ES 156 Signals and Systems 2008 Harvard SEAS

How to get MATLAB FAS computing: –Download from –Requires Windows 2000/XP/Vista, OSX, v10.4 or later –Request an on-campus or VPN network connection. HSEAS IT –Maxwell Dworkin Rooms G107-G111 Mathworks: –Student version is affordable and complete.

What is MATLAB Stands for MATrix LABoratory, created by Mathworks. MATLAB is a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numeric computation.

The MATLAB language MATLAB is built around the MATLAB language, sometimes called M-code or simply M. 1.The simplest way to execute M-code is to type it in at the prompt >> in the Command Window, one of the elements of the MATLAB Desktop. 2.Sequences of commands can be saved in a text file, typically using the MATLAB Editor, as a script or encapsulated into a function, extending the commands available. Help command

MATLAB Desktop Menu and toolbar Command History Workspace

Matrices & Vectors (Almost) all entities in MATLAB are matrices Easy to define: Use ‘,’ or ‘ ’ to separate row elements -- use ‘;’ to separate rows >> A = [16 3; 5 10] A = >> B = [ ] B =

Creating Vectors Create vector with equally spaced intervals >> x=0:0.5:pi x = Create vector with n equally spaced intervals >> x=linspace(0, pi, 7) x = Equal spaced intervals in logarithm space >> x=logspace(1,2,7) x = … Note: MATLAB uses pi to represent, uses i or j to represent imaginary unit

Creating Matrices zeros(m, n): matrix with all zeros ones(m, n): matrix with all ones. eye(m, n): the identity matrix rand(m, n): uniformly distributed random randn(m, n): normally distributed random magic(m): square matrix whose elements have the same sum, along the row, column and diagonal. Order of Matrix: m=no. of rows, n=no. of columns

Matrix operations ^: exponentiation *: multiplication /: division \: left division. The operation A\B is effectively the same as INV(A)*B, although left division is calculated differently and is much quicker. +: addition -: subtraction ‘: transpose

Array Operations Evaluated element by element.' : array transpose (non-conjugated transpose).^ : array power.* : array multiplication./ : array division Very different from Matrix operations >> A=[1 2;3 4]; >> B=[5 6;7 8]; >> A*B But: >> A.*B

Some Built-in functions mean(A): mean value of a vector max(A), min (A): maximum and minimum. sum(A): summation. sort(A): sorted vector median(A): median value std(A): standard deviation. det(A) : determinant of a square matrix dot(a,b): dot product of two vectors cross(a,b): cross product of two vectors Inv(A): Inverse of a matrix A

Indexing Matrices Given the matrix: Then: A(1,2) = A(3) = A(:,1) = [ ] A(1,2:3)=[ ] A = m n 1:m

Graphics - 2D Plots plot(xdata, ydata, ‘marker_style’); For example: Gives: >> x=-5:0.1:5; >> sqr=x.^2; >> pl1=plot(x, sqr, 'r:s');

Graphics - Overlay Plots Use hold on for overlaying graphs So the following:Gives: >> hold on; >> cub=x.^3; >> pl2=plot(x, cub,‘b-o');

Graphics - Annotation Use title, xlabel, ylabel and legend for annotation >> title('Demo plot'); >> xlabel('X Axis'); >> ylabel('Y Axis'); >> legend([pl1, pl2], 'x^2', 'x^3');

Graphics - Annotation

Graphics-Stem() stem() is to plot discrete sequence data The usage of stem() is very similar to plot() >> n=-10:10; >> f=stem(n,cos(n*pi/4)) >> title('cos(n\pi/4)') >> xlabel('n')

subplots Use subplots to divide a plotting window into several panes. >> x=0:0.1:10; >> f=figure; >> f1=subplot(1,2,1); >> plot(x,cos(x),'r'); >> grid on; >> title('Cosine') >> f2=subplot(1,2,2); >> plot(x,sin(x),'d'); >> grid on; >> title('Sine');

>> f=figure; >> x=-5:0.1:5; >> h=plot(x,cos(2*x+pi/3)); >> title('Figure 1'); >> xlabel('x'); >> saveas(h,'figure1.fig') >> saveas(h,'figure1.eps') Save plots Use saveas(h,'filename.ext') to save a figure to a file. Useful extension types: bmp: Windows bitmap emf: Enhanced metafile eps: EPS Level 1 fig: MATLAB figure jpg: JPEG image m: MATLAB M-file tif: TIFF image, compressed

Workspace Matlab remembers old commands And variables as well Each Function maintains its own scope The keyword clear removes all variables from workspace The keyword who lists the variables

File I/O Matlab has a native file format to save and load workspaces. Use keywords load and save. In addition MATLAB knows a large number of popular formats. Type “help fileformats” for a listing. In addition MATLAB supports ‘C’ style low level file I/O. Type “ help fprintf ” for more information.

Plot the following signals in linear scale Plot the following signals, use log scale for y-axis Plot the real part and imaginary part of the following signal For the signal in previous question, plot its phase and magnitude Practice Problems