Plotting Signals in MATLAB

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

CSE 123 Plots in MATLAB. Easiest way to plot Syntax: ezplot(fun) ezplot(fun,[min,max]) ezplot(fun2) ezplot(fun2,[xmin,xmax,ymin,ymax]) ezplot(fun) plots.
Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
2D Plots 1 ENGR 1181 MATLAB 12.
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.
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
Digital Image Processing Lecture11: Histogram Processing.
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.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
MATLAB GRAPHICS 2-D.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
EGR106 Week 6 MATLAB FILES Two Dimensional Plots Multiple Plots
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.
EGR106 Week 4 Two Dimensional Plots Multiple Plots Plot Formatting Homework.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All.
Plotting. Basic Plotting Two vectors of x and y values needed. Vectors need to be of the same length, but not necessarily of the same geometry. For example,
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
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.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Barbara/Pratik/Yu. Outline Matlab desktop M-files Variables Arrays Plots.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB – 2D Plots 1 Go to the class drive: ---> MatLab - Graphing ---> Seed Files.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Plot (x-values, y-values) >> x = linspace (-3, 3, 20); >> x = linspace (-3, 3, 20); >> y = 2*x – 1; >> y = 2*x – 1; >> plot (x, y) >> plot (x, y)
UW CSE 190p Section 7/26, Summer 2012 Dun-Yu Hsiao.
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,
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
EGR 115 Introduction to Computing for Engineers 2D Plotting – Part I Wednesday 17 Sept 2014 EGR 115 Introduction to Computing for Engineers.
ELG 3120 Lab 2 TAs Wei Zhang Ozgur Ekici (Section A) (Section B)
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
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.
CS100A, Fall 1998, Lecture 191 CS100A, Fall 1998 Lecture 19, Thursday Nov 05 Matlab Concepts: Matlab arrays Matlab subscripting Matlab plotting.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
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.
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.
Computer Application in Engineering Design
Plotting Chapter 5.
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25.
Course Information Do not rely on color to distinguish curves (due to black-white printout). Use different line styles to distinguish curves (solid, dashed,
Lecture 25: Exploring data
Two-Dimensional Plots
Matrices and Arrays.
Introduction To MATLAB
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
MATLAB How to use (using M-files) Double click this icon
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.
Plotting Multiple Graphs In The Same Plot
MATLAB How to use (using M-files)
Introduction to MATLAB Plotting LAB 3
CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Yang-Ming University, Taipei, Taiwan
How to Use MATLAB A Brief Introduction.
Introduction to Matlab
Presentation transcript:

Plotting Signals in MATLAB Lecture 4: Plotting Signals in MATLAB 1st semester 1439 - 2017 By: Elham Sunbu

Outline Graph in MatLab 2-D plotting 1. Creating and Type of graph 2. Using Basic Plotting Functions 3. Plotting Multiple graph in same plot 4. Formatting plots

Creating Graph in MATLAB Line Plot Pie Charts, Bar Plots, and Histograms Command Description bar, bar3 Bar graph 2-D, 3-D Pie, pie3 Pie graph 2-D, 3-D hist Histogram plot Command Description Plot, plot3 Create 2-D graph and 3-D plotyy 2-D line plots with y-axes on both left and right side Discrete Graph Command Description Stem, stem3 Plot discrete sequence data 2-D, 3-D stairs Stairstep graph

2-D Plotting - Specify x-data and/or y-data - Syntax: - Specify color, line style and marker symbol (Default values used if ‘clm not specified) - Syntax: Plotting single line: plot(xdata, ydata, 'color_linestyle_marker') Plotting multiple lines: If data is given, the information is entered as the elements of the vectors x and y. If the values of y are determined by a function from the values of x, than a vector x is created first, and then the values of y are calculated for each value of x. The PLOT functions is used to produce 2-dimensional curves, using x- and y-data matrices specified by the user. However, PLOT also accepts character-string arguments that designate various colors, line styles and marker symbols for the resulting line. For example, to produce a red dotted line with square markers at each data point, type: » plot(x, y, 'r:square') You can plot multiple lines at once, using pairs of x- and y-data. As with plotting single lines, the color, line style and marker information can be specified explicitly. However, if not specified, MATLAB automatically cycles through a predefined (but user settable) list of colors to identify each line. For example, the following statement plots three lines as a function of t (First = blue / Second = green / Third = red): » plot(t, y1, t, y2, t, y3) plot(x1, y1, 'clm1', x2, y2, 'clm2', ...)

Line Specification Three components can be specified in the string specifiers along with the plotting command. They are: Line style Marker symbol Color iers Meaning '-' Solid line (default) '--' Dashed line ':' Dotted line '-.' Dash-dot line

Line Specification Meaning Color Specifiers Blue b Cyan c Green g Black k Magenta m Red r Yellow y Meaning Marker down v circle o triangle left < diamond d triangle right > hexagram h up triangle ^ pentagram p x -mark x plus + point . square s star *

2-D Plotting - Example » x = 0:.1:2*pi; » y = sin(x); » plot(x,y) - Create a Blue Sine Wave » x = 0:.1:2*pi; » y = sin(x); » plot(x,y) In this example, the data plotted along the x-axis is defined as: » x=0:0.1:2*pi; The data plotted along the y-axis is defined as: » y=sin(x); Plot these data as follows (default = blue, solid line, no marker): » plot(x,y)

Adding a Grid - GRID ON creates a grid on the current figure - GRID OFF turns off the grid from the current figure - GRID toggles the grid state grid on

Controlling the Axes - Setting Axis Limits & Grids The axis command lets you to specify your own limits: axis([xmin xmax ymin ymax]) You can use the axis command to make the axes visible or invisible: axis on / axis off The grid command toggles grid lines on and off: grid on / grid off

Using Basic Plotting Functions - The following commands are useful when plotting: Note that all text must be put within ' '. Graphing functions MATLAB command Label the horizontal axis. xlabel('text') Label the vertical axis. ylabel('text') Attach a title to the plot. title('text') Change the limits on the x and y axis. axis([xmin xmax ymin ymax]) "Keep plotting in the same window." hold on Turn off the "keep-plotting-in-the-same-window-command". hold off using the strings to label various curves legend(‘string1’,’string2’,’string3’) Places the string (text) on the plot at coordinate x,y relative to the plot axes. text(x,y,’string’) The title (), xlabel (), and ylabel () commands take a string argument in single quotes in order to label the top of the plot, the x-axis, and the y-axis, respectively. The axis () command takes a 2 or 4 element vector as its argument where the minimum and maximum x values are set or the minimum and maximum x and y values are set. Matlab will probably complain loudly if either xmax or ymax is less than xmin or ymin. The use of the axis () command allows the user to override the default setting that Matlab would otherwise pick. It can be use to look closely at a small window of data which would otherwise be unclear if a lot of points where available. It can be particularly useful when making an interactive plot that needs to resize itself. The legend () command allows us to place a legend on a plot. The legend () command takes as its arguments a list of strings enclosed in single quotes that are the explanatory information you would like displayed next to a short sample of the line and data point display for a given set of data. The order of the strings must correspond to the order of the graphs that were added to the plot. In addition to the string, the legend () command can take a position argument that dictates where the legend is to be placed on the plot. The default is the upper right corner of the plot. The text () command takes three arguments: an x and y location to begin writing a string and the text string that you would like displayed. The string must be enclosed in single quotes. The x and y location must be supplied in the same scale that is being used for the x and y axes. In other words, the location of the text string is relative to the plot. Fixed screen locations do not exist.

Adding Additional Plots to a Figure PLOTTING MULTIPLE GRAPHS IN THE SAME PLOT Plotting two (or more) graphs in one plot: Using the plot command. 2. Using the hold on, hold off commands. In addition to supplying multiple vector pairs to the plot () command, we can create graphs with multiple plots by using the hold on/hold off commands. Once a plot () command has been issued and hold on specified, all subsequent plot () commands will be plotted on the initial graph. Axis properties will be maintained for subsequent plots. If line specifiers are not specified in the subsequent plots, Matlab will use the default order and colors when drawing additional plots on the graph. To return to the default situation in which each plot () command causes a new plot to be drawn in the graph window, the hold off command must be issued.

Subplots

Formatting Plots - A plot can be formatted to have a required appearance. - With formatting you can: Add title to the plot. Add labels to axes. Change range of the axes. Add legend. Add text blocks. Add grid.

Thank You