Tutorial 2 SEG7550 Introduction to MATLAB II

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 Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to Matlab
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
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 –
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.
MATLAB GRAPHICS 2-D.
Vectors and Plotting Selim Aksoy Bilkent University Department of Computer Engineering
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
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
Mathcad Variable Names A string of characters (including numbers and some “special” characters (e.g. #, %, _, and a few more) Cannot start with a number.
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.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
1 "A picture is worth a thousand words." Graphical representation is useful for: Error detection - you can locate outliers in a dataset, program bugs,
MATLAB Plotting With MATLAB 1. Two Dimensional Plots The xy plot is the most commonly used plot by engineers The independent variable is usually called.
Descriptive Statistics I: By the end of this class you should be able to: Palm: Section 7.1, 7.2 Program cords and delays in your music programs plot a.
INTRODUCTION TO MATLAB LAB# 01
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Sept. 26, 2005 Lecture 6 - By Paul Lin 1 CPET 190 Lecture 6 Problem Solving with MATLAB
Introduction to Matlab
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Deniz Savas & Mike Griffiths May 2015.
Example 2-5 Histograms Capital Credit Union Issue: Analyze credit card balances for Capital Credit Union customers using a frequency distribution and histogram.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
An Introduction to Programming in Matlab Emily Blumenthal
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
ECE 1304 Introduction to Electrical and Computer Engineering
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.
Introduction to MATLAB
Signals in Matlab Matlab as a name stands for Matrix Laboratory.
Introduction to Mat lab
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25.
Introduction to MATLAB
Ch3 Graphics Overview of Plotting Editing Plots
Lecture 25: Exploring data
Two-Dimensional Plots
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
Net 222: Communications and networks fundamentals (Practical Part)
StatLab Matlab Workshop
Guide to Using Excel 2003 For Basic Statistical Applications
Lecture 10 2D plotting & curve fitting
MATLAB How to use (using M-files) Double click this icon
MATLAB Tutorial Dr. David W. Graham.
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 – 2D Plots 2 MATLAB has many built-in functions and commands to create various types of plots. Instructor notes: We start with an example of some.
MATLAB How to use (using M-files)
Introduction to MATLAB Plotting LAB 3
Plotting Signals in MATLAB
How to Use MATLAB A Brief Introduction.
Introduction to Matlab
Introduction to Excel 2007 Part 3: Bar Graphs and Histograms
Chapter 8 Using Document Collaboration and Integration Tools
Presentation transcript:

Tutorial 2 SEG7550 Introduction to MATLAB II 25th, Sep., 2009

Outline Source of financial data Generate graphs in MATLAB Review programs in class

Histogram plot n = hist(Y) bins the elements in vector Y into 10 equally spaced containers and returns the number of elements in each container as a row vector. n = hist(Y,x) where x is a vector, returns the distribution of Y among length(x) bins with centers specified by x. For example, if x is a 5-element vector, hist distributes the elements of Y into five bins centered on the x-axis at the elements in x, none of which can be complex.

Histogram plot Example: x = -4:0.1:4; y = randn(10000,1); hist(y,x)

Plot (basic) plot(X,Y) plots vector Y versus vector X. plot(Y) plots the columns of Y versus their index Title: use function ‘title()’ X,Y axis labels: use function ‘xlabel()’ and ‘ylabel() ’

Plot multiple data sets in one graph Example: X=0:0.1:10; Y1=X.^2-10.*X+15; Y2=-X.^2+10.*X; Y3=0.5.*(X.^2); plot(X,Y1,X,Y1,X,Y3) title(‘graph’) xlabel(‘x’) ylabel(‘y’)

Plot multiple data sets in sub graphs subplot Create axes in tiled positions. H = subplot(m,n,p), or subplot(mnp), breaks the figure window into an m-by-n matrix of small axes, selects the p-th axes for for the current plot, and returns the axis handle. The axes are counted along the top row of the Figure window, then the second row, etc. For example, subplot(2,1,1), plot(X,Y1) subplot(2,1,2), plot(X,Y2)

Plot multiple data sets in sub graphs subplot('position',[left bottom width height]) creates an axis at the specified position in normalized coordinates (in in the range from 0.0 to 1.0). For example subplot(2,2,[1 3]) plot(X,Y3) subplot(2,2,2) plot(X,Y1) subplot(2,2,4) plot(X,Y2)

Plot multiple data sets in sub graphs Or subplot(2,2,1:2) plot(X,Y3) subplot(2,2,3) plot(X,Y1) subplot(2,2,4) plot(X,Y2)

Distinguish two plots

Distinguish two plots For example: plot(X,Y1,’r-.’,X,Y2,’bo’)

Legend legend(string1,string2,string3 ., ...) puts a legend on the current plot using the specified strings as labels legend(H,string1,string2,string3, ...) puts a legend on the plot containing the handles in the vector H using the specified strings as labels for the corresponding handles. legend(AX,...) puts a legend on the axes with handle AX. legend(M), where M is a string matrix, and LEGEND(H,M) where H is a vector of handles to lines and patches also works. legend('off') removes the legend from the current axes.

Legend legend() with no arguments refreshes the current legend, if there is one. If there are multiple legends present, legend(legendhandle) refreshes the specified legend. legend(...,Pos) places the legend in the specified location: 0 = Automatic "best" placement (least conflict with data) 1 = Upper right-hand corner (default) 2 = Upper left-hand corner 3 = Lower left-hand corner 4 = Lower right-hand corner -1 = To the right of the plot

Legend To move the legend, press the left mouse button on the legend and drag to the desired location. Legend() works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. Double clicking on a label allows you to edit the label.

Text plot(0:pi/20:2*pi,sin(0:pi/20:2*pi)) text(X,Y,'string') adds the text in the quotes to location (X,Y) on the current axes, where (X,Y) is in units from the current plot. If X and Y are vectors, TEXT writes the text at all locations given. If 'string' is an array the same number of rows as the length of X and Y, TEXT marks each point with the corresponding row of the 'string' array. Example plot(0:pi/20:2*pi,sin(0:pi/20:2*pi)) text(pi,0,' \leftarrow sin(\pi)','FontSize',18)

Print Print Figure or model. Save to disk as image or M-file. print: it sends the current figure to your current printer. The size and shape of the printed output depends on the Figure's PaperPosition[mode] properties and your default print command as specified in your PRINTOPT.M file. print filename: it directs the output to the PostScript file designated by filename. If filename does not include an extension, print appends an appropriate extension. print -dformat filename: it exports the figure to the specified file using the specified graphics format, (such as bmp eps and jpeg).

Review programs in class The models:

Review programs in class The models:

Review programs in class Some functions round: Round to nearest integer diff: Differences and approximate derivatives diff(x) calculates differences between adjacent elements of X. Load: load filename loads all the variables from the file specified by filename.

System Identification Toolbox Estimate linear and nonlinear mathematical models of dynamic systems from measured data. Simulate output of a system for given input Predict future outputs on previous observations of inputs and outputs

Manuals for System Identification Toolbox Getting started http://www.mathworks.com/access/helpdesk/help/pdf_doc/ident/ident_gs.pdf User guide http://www.mathworks.com/access/helpdesk/help/pdf_doc/ident/ident.pdf

Review programs in class Some functions idinput: idinput generates input signals of different kinds, which are typically used for identification purposes. u is returned as a matrix or column vector. u = idinput(400, 'rbs', [0 0.3]); 400 is # of data generated. rbs means these random data are from gaussian distribution [0,0.03] is the lower and upper bound. poly2th:Constructs a "theta-matrix" from given polynomials. th0 = poly2th(A, B, C); th0 contains parameters of the equation: A(q) y(t) = B(q) u(t-1) + [C(q)] e(t)

idsim: Simulate systems specified in theta format Some functions idsim: Simulate systems specified in theta format y = idsim([u e], th0); u is data, e is noise, and th0 is the parameter. idplot: Plot input-output data. th2ff: Compute the frequency response and standard deviations of a theta format model. ffplot: Plot frequency response and spectra

Review programs in class Some functions: armax: Estimate the parameters of an ARMAX or ARMA model. m = armax(data,orders) returns an idpoly model m with estimated parameters and covariances (parameter uncertainties). Estimates the parameters using the prediction-error method and specified orders. th1 = armax([y u], [2 2 2 1]); [y,u] is data. [2 2 2 1]is order. The first three is the order of parameters and the last one is for lag (or delay) bodeplot: Plot Bode frequency response and return plot handle. A Bode plot is a graph of the logarithm of the transfer function of a linear, time-invariant system versus frequency, plotted with a log-frequency axis, to show the system's frequency response.

Useful materials for matlab Econometrics Toolbox: by James P. LeSage http://www.spatial-econometrics.com/ UCSD GARCH http://www.kevinsheppard.com/wiki/UCSD_GARCH