Plotting 1.Overview 2.plot in 2D 3.Plot in 3D 4.Other possible charts 5.Engineers: label your plots! 6.Plots & Polynomial.

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
Empirical Model Building I: Objectives: By the end of this class you should be able to: find the equation of the “best fit” line for a linear model explain.
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.
® Microsoft Office 2010 Excel Tutorial 4: Enhancing a Workbook with Charts and Graphs.
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.
MATLAB GRAPHICS 2-D.
Graphing With Excel 2010 University of Michigan – Dearborn Science Learning Center Based on a presentation by James Golen Revised by Annette Sieg…
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
1 Introduction to MatLab MatLab stands for Matrix Laboratory. As the name suggests most of the programming operations have as input or output a matrix.
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.
Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All.
Physics Graphing Using Excel. Advantages of Graphing with Spreadsheet Programs Can be fast. Handles lots of data and multiple calculations. Precise calculation.
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,
Graphing in Excel X-Y Scatter Plot SCI 110 CCC Skills Training.
An introduction to Plotting in MATLAB Rikard Johansson Department of Biomedical Engineering (IMT) Linköping University
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication ENGINEERING SERIES.
Graphing in Science. Types of Charts  Most scientific graphs are made as line graphs.  However, occasionally bar graphs, pie charts, or scatter plots.
CMPS1371 Introduction to Computing for Engineers NUMERICAL METHODS.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Array Math. I. Definition MATLAB is known for its mathematical power! – It does vector and MATRIX operations automatically (most languages require you.
Plotting II: By the end of this class you should be able to: Create a properly formatted engineering graph Create graphs of a function Place multiple plots.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
CMPS 1371 Introduction to Computing for Engineers PLOTTING.
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
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.
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
Microsoft Office Illustrated Fundamentals Unit I: Working with Charts.
MAE 1202: AEROSPACE PRACTICUM An Introduction to MATLAB: Part 2 Mechanical and Aerospace Engineering Department Florida Institute of Technology Developed.
Graphs in Physics PowerPoint #4. A graph is… A convenient way to show data.
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
Graphing with Excel The Basics. Working With Excel The spreadsheet program Excel is useful for constructing data tables and graphs The results can easily.
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication Linda Driskill, Gang Cheng,
Recording Data. Record Data Record Data in a Table or Chart. Make sure to have as much information as possible Record Everything that you do.
DAY 6: MICROSOFT EXCEL – CHAPTER 3 Sravanthi Lakkimsetty September 2, 2015.
Requirements of a good GRAPH. GRAPH  Title (usually “dependent” vs. “independent”)  Go Big (cover at least ½ the page in both directions) This increases.
Numerical Analysis 3D Plots. A numerical method is a technique for computing a numerical approximation of the solution to a mathematical problem.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
Recap Plots with More than one Line Plots of Complex Arrays Line, Color and Mark Style Axis Scaling and Annotating Plots Subplots Polar Plots Logarithmic.
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.
1-d Arrays & Plotting.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Regression Analysis in Microsoft Excel MS&T Physics 1135 and 2135 Labs.
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Deniz Savas & Mike Griffiths May 2015.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
Graphing. Line Graphs  Shows a relationship where the dependent variable changes due to a change in the independent variable  Can have more than one.
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.
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.
Lecture 25: Exploring data
How to make great graphs that make sense!
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
Lecture 10 2D plotting & curve fitting
Plotting Signals in MATLAB
Designing Effective Graphics Using MATLAB
Presentation transcript:

Plotting 1.Overview 2.plot in 2D 3.Plot in 3D 4.Other possible charts 5.Engineers: label your plots! 6.Plots & Polynomial

1. Plots & Charts, overview Plotting functions plot(), plot3(), polar(), meshgrid() Charting functions pie(), pie3(), bar(), bar3(), bar3h(), hist(), errorbar() Plot-related functions polyfit(), polyval(), text(), title(), xlabel(), ylabel() 2

2. Plots Create a graph of y vs. x plot(x, y) %order of arguments matters Example: 100 data-points x = linspace(-pi, pi); y = sin(x); plot(x, y) By default, plot() connects the data-points with a solid line without markers. 3 3

2. Plots, cont. Let us try with less data-points: x = linspace(-pi, pi, 10); y = sin(x); plot(x, y); Notice that the curve is less smooth This is another reason why linspace() is friendly to use: easily fixable. 4

2. Plots: line specifiers A third argument can be added in the plot function-call: plot(x,y, _____) The third argument must be a string, made of up to three components: – One component for the line’s color – One component for the line-style – And one component for the marker symbol (the symbol at each data point 5 5

2. Plots: lineSpecs - color Specify the color only: 6 plot(x, y, ‘r’); 6

2. Plots: lineSpecs – line style Color and line-style: 7 plot(x, y, ‘r:’); 7 (none): no line

2. Plots: lineSpecs - marker Color, type of line and data-marker: 8 plot(x, y, ‘r:d’);

2. Plots: line specifier, cont. If only the data-points must show, leave out the line-style: plot(x, y, 'rd') Forgot all the options? >> doc plot 9 9

2. Plots: multiple plots Repeat the series of 3 arguments to combine multiple plots on 1 graph. Example: X = linspace(-2*pi,2*pi,50); Ysine = sin(X); Ycosine = cos(X); plot(X,Ysine,'r:o',X,Ycosine,'b--d') The string argument is unnecessary. MATLAB will rotate through the default colors to make sure each plot has a different color. The other 4 arguments are MANDATORY. 10

2. Plots: hold on/off At default mode, the plot() command erases the previous plots before drawing new plots. If subsequent plots are meant to add to the existing graph, use: hold on, which holds the current plot. When you are done, use hold off to return to default mode. hold, by itself, toggles the hold modes. 11

>> hold on >> plot(x1,sin(2*x1),'g’) 2. Plots: hold on/off, cont. 12 >> x1 = linspace(0,pi,25); >> plot(x1,sin(x1),'r') * Range of the axis will be automatically adjusted.

Example: Airfoil Lift Vortex Panel Method + Boundary Layer analysis – A numerical Computational fluid dynamics – Models the lifting surface of a wing as an infinitely thin sheet of discrete vortices – Used to compute lift and induced drag & predict separation/stall 13

3. Plots: 3 dimensions plot3() makes a 3D plot – requires x, y, and z data. 14

Meshgrid() 15 Given: x = [1 2 3]; y = [4 5]; Evaluate: f(x,y) = x + y In other words, I need to evaluate (x+y) at every pair of points between x and y.

Meshgrid(), cont. 16 To make a useful plot, it is necessary to match up each x with each y before computing z. The function meshgrid() makes this easy to do.

3. Plots: 3 dimensions, cont. x = linspace(-pi, pi); y = linspace(-pi, pi); [X, Y] = meshgrid(x, y); Z = sin(X).^3 - cos(Y).^2; plot3(X, Y, Z) Creates two arrays X, Y where each value of x is matched with each value of y 17

4. Other Possible Charts polar() creates polar coordinate plots: x = linspace(-pi, pi); y = cos(x) - sin(x).^2; polar(x, y) 18

4. Other Possible Charts, cont. pie(), pie3(), bar(), bar3(), bar3h(), hist(), errorbar() 19 pie3() 19 Much like Excel offers: >> x = >> pie3(x)

4. Other Possible Charts, cont. pie(), pie3(), bar(), bar3(), bar3h(), hist(), errorbar() 20 Much like Excel offers: bar3h() x = >> bar3h(x)

4. Other Possible Charts, cont. pie(), pie3(), bar(), bar3(), bar3h(), hist(), errorbar() 21 errorbar()

Example: Flight Delays 1.Percentage of flights delayed 1.Percentage of those flights delayed due to carrier’s fault 2.Percentage of those flights delayed due to weather 3.Percentage of those flights delayed due to NAS 4.Percentage of those flights delayed due to security 5.Percentage of those flights delayed due to late flights 2.Percentage of flights arrived on time 3.Present result in table 4.If time, present results in pie chart 22

Example: Plot results Plot the results for 2010 and

4. Other Possible Charts, cont. As with all the MATLAB possibilities, use… 24 F1 = Help 24

5. Engineers: Complete Plots The following built-in functions should be applied to ALL graphs created: title() %title on figure xlabel() %x-axis label ylabel() %y-axis label zlabel() %z-axis label Each function takes 1 ‘string’ argument only and has no return-value. 25

5. Engineers: Complete Plots Additional built-in function: text() Example: text(1, -2, -2, 'Cool plot!') 26

5. Engineers: Complete Plots Built-in function: grid on COMMAND line typed in the script, after a plot command. It stands alone on one line, requires no arguments, and returns no value. 27

5. Engineers: Complete Plots Additional built-in functions: legend(), xlim, ylim, axis 28

Plots All plots MUST have a title and axis labels! All plots with more than 1 line should have a legend with appropriate labeling. Grids should be appropriate for the problem Plot limits should be appropriate for the problem – Is there a “0” value? As with using fprintf and input, a happy grader is a generous grader – make your plots easy to read/understand and your grader will be happier. If you see the phrase “suitable for technical presentation,” assume that means title, axis labels, grid (where appropriate), legend (where appropriate), and appropriate axis limits.

6. Plotting & Polynomials Plot-related functions that try to find an equation that links data-points: polyfit(), polyval() polyfit() is like linear regression which finds the curve that best fits the data-points. polyfit() attempts to fit a polynomial – not a line. It mainly finds the coefficients of the polynomial that best fits the data given. polyval() is used to evaluate the polynomial at specified points. It makes use of the coefficients generated by polyfit(). – It is frequently used to generate a plot. 30

6. Plotting & Polynomials, cont. clear clc %generate tables of x, and y data = [1, 50; 4, 4900; 7, 4600; 10, 3800; 70, 1300; 100, 850; 300, 0.2e9; 700, 1.2e9; 1000, 1.2e9]; x = data(:, 1)'; y = data(:, 2)'; %plot data points, omit line plot(x, y, 'd') hold on %combine future plots on this one %find best-fit polyn. of order 3 coeff = polyfit(x, y, 3) px = linspace(min(x), max(x), 100); py = polyval(coeff, px); plot(px, py) 31 Remember that fitting a curve does NOT mean hitting every data-point! 31

Example: Beam Deflection Cantilever Beam Deflection – Determine the equation of the polynomial from experimental data. 32

Key Ideas Plotting any kind of graphs mostly requires vectors of identical dimensions: (x,y) (x, y, z) (r, theta, z)... hold on allows multiple plots to be combined together. The independent variable is the first argument. IT IS A COMMON MISTAKE TO SWAP THEM. All functions are easily explained in the help, usually with examples that show how to place arguments. As engineer, remember all graphs must be labeled correctly. For mathematical analysis, polyfit() and polyval() allow to fit a curve through data-points. 33