ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
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.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/29/2003.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
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 Jianguo Wang CSSCR September 2009.
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 and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
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.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
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.
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
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.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Barbara/Pratik/Yu. Outline Matlab desktop M-files Variables Arrays Plots.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
A simple classification problem Extract attributes Pattern Pattern recognition decision x C1 C2.
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.
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.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
An Introduction to Programming in Matlab Emily Blumenthal
전자장 1 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
NoViC, Dept. of Mechanical Eng Acoustics Lab., NoViC 1. Download Matlab 2.
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.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Prof. N. P. Jadhav Presented by. Overview of MATLAB environment MATLAB is an interactive, matrix-based system for scientific and engineering numeric computation.
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Release Numbers MATLAB is updated regularly
Introduction to Mat lab
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
MATLAB How to use (using M-files) Double click this icon
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files)
INTRODUCTION TO MATLAB
Plotting Signals in MATLAB
Announcements P3 due today
Matlab Basics Tutorial
Presentation transcript:

ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1

ELG 3120 Signal and System Analysis 2 I. MATLAB DESKTOP

ELG 3120 Signal and System Analysis 3

ELG 3120 Signal and System Analysis 4  Command Window  Use the command window to enter variables and run functions and M-files.  For example:  A = ones(5,5);

ELG 3120 Signal and System Analysis 5  Command History  Statements you enter in the Command window are logged in the Command History. In the Command History, you can view previously run statements, and copy and execute selected statements.

ELG 3120 Signal and System Analysis 6  Workspace Browser (1)  The MATLAB workspace consists of the set of variables (named arrays) built up during a MATLAB session and stored in memory.  You add variables to the workspace by using functions, running M-files and loading saved workspaces.  To delete variables from the workspace, select the variable and select Delete from the Edit menu. Alternatively, use the “clear” function.  Save the workspace to a MAT-file: File  Save Workspace As  Read a MAT-file: File  Import Data

ELG 3120 Signal and System Analysis 7  Workspace Browser (2)

ELG 3120 Signal and System Analysis 8  Workspace Browser (3) – Array Editor  Double-click a variable in the Workspace browser to see it in the Array Editor.  Use the Array Editor to view and edit a visual representation of one or two-dim. arrays, strings, and cell arrays of strings that are in the workspace.

ELG 3120 Signal and System Analysis 9  Current Directory Browser (1)  MATLAB file operations use the current directory and the search path as reference points. Any file you want to run must either be in the current directory or on the search path.  A quick way to view or change the current directory is by using the Current Directory field in the desktop toolbar as shown below.

ELG 3120 Signal and System Analysis 10  Current Directory Browser (2)

ELG 3120 Signal and System Analysis 11  Editor Window (1)  Use the Editor/Debugger to create and debug M- files, which are programs you write to run MATLAB functions. The Editor/Debugger provides a GUI for basic text editing, as well as for M-file debugging  Create a new M-file: File  New  M-file  Open an M-file: File  Open

ELG 3120 Signal and System Analysis 12  Editor Window (2)  “%” is for comments.  Define some variables: x = 1:5; y= 3*x+1;  Use MATLAB functions and programming language.  Run the M-file: (if the M-file is under the current directory)  In the command window, input the name of the M-file and then ENTER.  In the editor window, press F5.

ELG 3120 Signal and System Analysis 13  Help Browser  Use the Help browser to search and view documentation and demos for all your MathWorks products. The Help browser is a Web browser integrated into the MATLAB desktop that displays HTML documents.  To open the Help browser, click the help button in the toolbar, or type “helpbrowser” in the Command Window.

ELG 3120 Signal and System Analysis 14

ELG 3120 Signal and System Analysis 15 II. MATLAB BASICS

ELG 3120 Signal and System Analysis 16  Matrix MATLAB is designed to work with matrices, but you can also input scalars and vectors since they can be considered as matrices with dimension 1x1 (scalars) and 1xn or nx1 (vectors).  Entering matrix  >>z = [9] Assigns the scalar value 9 to the variable z  >>a =[ 1 3 5] Defines a 1x3 row vector (any space(s) or tab will denote a new column).  >>b = [2;4;6] Defines a 3x1 column vector (semicolon always denotes new row).  >>A = [2 1 1;0 1 0;3 0 2] Defines a 3x3 matrix in the variable A.

ELG 3120 Signal and System Analysis 17  Transpose and diag  A = [2 1 1; 0 1 0; 3 0 2];  A’ gives the transpose of A  diag(A) gives the diagonal elements of A  Subscripts  The element in row i and column j of A is denoted by A(i,j). A(1,1) =2  The colon operator  1:10 is a row vector containing the integers from 1 to 10:  To obtain nonunit spacing, specify an increment. For example, 100:-7:50 is

ELG 3120 Signal and System Analysis 18  The colon operator  Subscript expressions involving colons refer to portions of a matrix. A(1:k,j) is the first k elements of the j th column of A. A(:,j) is the jth column of A. A(i,:) is the ith row of the A.

ELG 3120 Signal and System Analysis 19  Operations  MATLAB supports numerous matrix operations and reminds you about the dimension requirements of the operations.  Define: a=[1 3 5]; b=[2;4;6];  >> c=a*b Computes the dot product yielding the scalar c with the value 44.  >> d=a ’ +b Matrix addition or subtraction yields the column vector d=[3;7;11].

ELG 3120 Signal and System Analysis 20  Plotting (1)  MATLAB supports a number of plot types with the ability to create custom graphs.  The simplest x-y type plot can be created using plot(x,y) where x and y are vectors with a list of values stored in them.  Other plot commands including: loglog, semilogx, semilogy, bar, stem, polar, plot3, contour, mesh and surf. To find out about the syntax for any of the plot commands you can type help inside of MATLAB.  The figure plotted will be shown in the Figure Window.

ELG 3120 Signal and System Analysis 21  Plotting (2)  Example 1: Using the colon to create lists and generating a plot  >>x=[1:.5:10] Defines a vector x that goes from 1 to 10 by 0.5. The colon is used to both create a list using the syntax [lower:increment:upper] and to select specific portions of a matrix.  >> y=2*x Defines a vector y with values equal to twice the values in x.  >>plot(x,y) Creates a simple x-y plot of the data stored in the vectors x and y.

ELG 3120 Signal and System Analysis 22

ELG 3120 Signal and System Analysis 23  Plotting (3)  Adding text, setting scales and styles  >> axis([xmin xmax ymin ymax]) Sets the x and y scales to the values you specify  >> title('title text') Places a title above the plot. The commands xlabel('xtitle text') and ylabel('ytitle text') place a titles along the x and y- axes, respectively.  >>text(x,y,'your text') Places any text string at the graph coordinates (x, y)

ELG 3120 Signal and System Analysis 24  Plotting (4)  Styles including color and line type can be specified by using a 2 or 3 character string inside the plot command immediately following the y variable. For example, the command plot(x,y,'r--') will produce a red dashed line. The available color and line type variables are given below:  For color: y yellow; m magenta; c cyan; r red; g green; b blue; w white; b black  For line type:. point; o circle; x x-mark; + plus; * star; - solid; : dotted; -. dashdot; -- dashed  Plotting more than one data set on an a single axis can be accomplished by using the command hold on and then plotting the additional data followed by a hold off command.

ELG 3120 Signal and System Analysis 25  Plotting (5)  Example2: simple plots  The following sequence of commands plots the graph of the sine function between 0 and π, provided that the two arrays have the same number of elements. >> x = 0:pi/90: pi; >> y = sin(x); >> plot(x, y) >> grid on >> xlabel(‘x, radians’) >> ylabel(‘sin(x)’)

ELG 3120 Signal and System Analysis 26

ELG 3120 Signal and System Analysis 27  Programming Matlab  Calling M-files  Sequences of MATLAB commands can be written to files with the extension m, appropriately called M-files. Entering the name of the file (without the extension!) causes automatic execution of all the statements. In their simplest form, such files are called script files.

ELG 3120 Signal and System Analysis 28  Help commands  Important commands for MATLAB can be counted as help, lookfor, helpdesk and helpwin. Pressing the up-arrow “↑” gives the previous command that was typed, which might be convenient while typing long codes. Finally, if you are sure about your code and MATLAB doesn’t give you the correct output, you always have the right to ask ‘why’.  >> why

ELG 3120 Signal and System Analysis 29 Good Luck!!!!