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,

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
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 1.Overview 2.plot in 2D 3.Plot in 3D 4.Other possible charts 5.Engineers: label your plots! 6.Plots & Polynomial.
Part 1 Chapter 2 MATLAB Fundamentals
MATLAB Fundamentals.
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication ENGINEERING SERIES.
1 Introduction to MATLAB MATLAB is all of the following: 1.Computational environment 2.Plotting software 3.Programming language Typical applications: 1.Calculations.
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()
1 "A picture is worth a thousand words." Graphical representation is useful for: Error detection - you can locate outliers in a dataset, program bugs,
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
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.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
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.
MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D.
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)
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.
ELG 3120 Lab 2 TAs Wei Zhang Ozgur Ekici (Section A) (Section B)
MATLAB Jirawat Kanjanapitak (Tae). What is MATLAB A computer program for doing numerical computation including; Arithmetic, Polynomials, Graphics, 2-D.
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
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,
Plotting. 2 Initializing Vectors colon operator x = 1:2:10 x = y = 0:0.1:0.5 y =
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.
Session III Plotting in MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU MATLAB Tutorials.
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
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25: Exploring data
Matrices and Arrays.
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
Plotting Multiple Graphs In The Same Plot
MATLAB How to use (using M-files)
Introduction to MATLAB Plotting LAB 3
Plotting Signals in MATLAB
Designing Effective Graphics Using MATLAB
How to Use MATLAB A Brief Introduction.
Introduction to Matlab
Presentation transcript:

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, x values may be in a column vector, and the y values may be in a row vector.

LINSPACE function LINSPACE and LOGSPACE functions are often used for generating vectors for plotting operations. Usage: linspace(start-value, end-value, #-of-points) logspace(log(start-value), log(end-value), #-of-points) Example: x= linspace(0, 4*pi, 100); y= sin(x); plot(x, y);

Plotting single series Example: x= linspace(0, 4*pi, 100); y= sin(x); plot(x, y);

Plotting multiple series Example: x= linspace(0, 4*pi, 100); y= sin(x); plot(x, y); z= 0.5*cos(x); hold on; plot(x, z);

Plotting multiple series-2 Example: x= linspace(0, 4*pi, 100); y= sin(x); z= 0.5*cos(x); plot(x, y, x, z); Notice that each serie is represented by a different color.

Plotting multiple series-3 It is also possible to have different x-vectors Example: x1= linspace(0, 2*pi, 100); x2= linspace(2*pi, 4*pi, 100); y= sin(x1); z= 0.5*cos(x2); plot(x1, y, x2, z);

Plotting multiple series-4 Another alternative is using a single (or multiple) x column vector(s), with multiple y column vectors. In case the x coordinates are the same for all y functions, the same x column vector can be used for all plotted functions. Multiple y column vectors can be grouped into a matrix. In case the x coordinates are different for y functions, different x column vectors can also be grouped into a matrix.

Plotting multiple series-4 (example) x= linspace(0, 4*pi, 100)'; y1= sin(x); y2= 4*cos(x); y3= x.*sin(x); y= [y1 y2 y3]; plot(x, y);

Adding titles Done by using title(), xlabel() and ylabel(). Example: x= linspace(0, 4*pi, 100); y= sin(x); plot(x, y); title('Plot of sin(x)'); xlabel('x (radians)'); ylabel('sin(x)');

Adding legend x= linspace(0, 4*pi, 100); y1= sin(x); y2= 4*cos(x); y3= x.*sin(x); plot(x, y1, x, y2, x, y3); legend('sin(x)', '4cos(x)', 'x.sin(x)'); title('Various functions'); xlabel('x (radians)');

Legend placement General form of the legend command: legend(legend1, legend2,..., legendn, place) Place constant has the following meanings:  1: Top right  2: Top left  3: Bottom left  4: Bottom right If the Place constant is omitted, it is assumed to be 1.

Formatting series In MATLAB plots, it is also possible to modify the visual appearance of the plotted lines. The following properties can be modified:  Line styles,  Line colors,  Markers at data points. The relevant format codes are written after each x-y vector pair that will receive the formatting. Example: plot(xvector1, yvector1, format1,..., xvectorn, yvectorn, formatn)

Marker, line style & color codes.Point oCircle xX-mark +Plus *Star sSquare dDiamond vTriangle (down) ^Triangle (up) <Triangle (left) >Triangle (right) pPentagram hHexagram -Solid :Dotted -.Dashdot --Dashed yYellow mMagenta cCyan rRed gGreen bBlue wWhite kBlack

Formatting series: Example The following code formats each serie differently: x= linspace(0, 4*pi, 100); y1= sin(x); y2= 4*cos(x); y3= x.*sin(x); plot(x, y1, 'gs', x, y2, 'kp:', x, y3, 'r-');

Background color The background color can be modified using the WHITEBG command. Using the command without arguments toggles the background color between black and white. It is also possible to specify a different backround color using the color codes defined for lines. Example: >>whitebg('y');% Yellow background

Grid GRID ON: Places a grid on the current plot. GRID OFF: Removes the grid from the current plot. GRID: Toggles grid.

Axes limits The lower and upper limits of the plot in the x- and the y-directions can be specified using the AXIS command. Syntax:  AXIS([Xmin Xmax Ymin Ymax])  AXIS AUTO

Grid & axis example grid on; axis([0 2*pi -1 5]);

Placing text on a plot Done using the text command: text(x-coord, y-coord, text-string); Examples: text(2, 4, 'Sines'); text(2, 3, '\alpha\beta'); text(2, 2, '\Gamma\Omega');