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.

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

Lecture 5.
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Chapter 11 Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.
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.
Fall 2006AE6382 Design Computing1 Three Dimensional Plotting Learning Objectives –Understand the anatomy of a 3D plot –Basics of constructing plots in.
MATLAB GRAPHICS 2-D.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
Using Excel for Data Analysis in CHM 161 Monique Wilhelm.
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
Instructor: Professor Cora Martinez, PhD Department of Civil and Environmental Engineering Florida International University.
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication ENGINEERING SERIES.
 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
C51BR Applications of Spreadsheets 1 Chapter 16 Getting Started Making Charts.
CMPS 1371 Introduction to Computing for Engineers PLOTTING.
Plotting – 3-Dimensional. 3D Plots versus 2D Plots 3-dimensional plots, in contrast to 2-dimensional ones, has a third axis (often called the z-axis).
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.
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.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
Examples of different formulas and their uses....
Data Presentation & Graphing Introduction to Mechanical Engineering The University of Texas-Pan American College of Science and Engineering.
Recap Summary of Chapter 6 Interpolation Linear Interpolation.
MATLAB for Engineers, by Holly Moore. ISBN © 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
CTS130 Spreadsheet Lesson 9 - Building Charts. What is a Chart? A chart is a visual display of information in a worksheet. Charts can help you make comparisons,
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication Linda Driskill, Gang Cheng,
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Return to Outline Copyright © 2011 by Maribeth H. Price 3-1 Labeling and annotation.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
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.
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. Tables, Charts, and Graphs Microsoft Word & Excel 2003.
June 14, ‘99 COLORS IN MATLAB.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Excel Lesson 5 Working with Multiple Worksheets and Charts Microsoft Office 2010 Introductory Pasewark & Pasewark.
EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 2 Friday 07 Nov 2014 EGR 115 Introduction to Computing for Engineers.
Program design and algorithm development We will consider the design of your own toolbox to be included among the toolboxes already available with your.
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.
More Matlab Graphics and GUI Graphics subplots some useful commands 3D graphics GUI GUI controls The callback property Other essential properties.
An Introduction to Programming in Matlab Emily Blumenthal
EEE 242 Computer Tools for Electrical Engineering
Lecture 17 More Plotting Chapter 12 Matrices. Outline from Chapter D Plotting 11.4 Surface Plots 11.5 Interacting with Plotted Data.
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.
Plotting ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Reading and Writing Image Files
Images In Matlab.
Plotting Chapter 5.
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25.
Ch3 Graphics Overview of Plotting Editing Plots
Lecture 25: Exploring data
Two-Dimensional Plots
MATLAB How to use (using M-files) Double click this icon
Using Charts in a Presentation
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files)
Introduction to MATLAB Plotting LAB 3
CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Plotting Signals in MATLAB
Designing Effective Graphics Using MATLAB
Presentation transcript:

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 Plots Bar Graphs and Pie Charts Histograms X-Y Graphs with two Y-axes

Function Plots

Three Dimensional Line Plots The plot3 function is similar to the plot function, except that it accepts data in three dimensions Instead of just providing x and y vectors, the user must also provide a z vector These ordered triples are then plotted in three-space and connected with straight lines For example: clear, clc x = linspace(0,10*pi,1000); y = cos(x); z = sin(x); plot3(x,y,z) grid xlabel('angle'), ylabel('cos(x)') zlabel('sin(x)') title('A Spring') The title, labels, and grid are added to the graph in the usual way, with the addition of zlabel for the z -axis. The coordinate system used with plot3 is oriented using the right-handed coordinate system familiar to engineers

Surface Plots Surface plots allow to represent data as a surface Two types of surface plots Mesh plots Surf plots

Mesh Plots There are several ways to use mesh plots They can be used to good effect with a single two-dimensional mxn matrix In this application, the value in the matrix represents the z- value in the plot The x- and y- values are based on the matrix dimensions Take, for example, the following very simple matrix: z = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10; 2, 4, 6, 8, 10, 12, 14, 16, 18, 20; 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; The code mesh(z) xlabel('x-axis') ylabel('y-axis') zlabel('z-axis') generates the graph

Explanation of Graph The graph is a “mesh” created by connecting the points defined in z into a rectilinear grid Notice that the x -axis goes from 0 to 10 and y goes from 1 to 3 The matrix index numbers were used for the axis values

Mesh Plots Continued…. The mesh function can also be used with three arguments: mesh(x,y,z) In this case, x is a list of x -coordinates, y is a list of y -coordinates, and z is a list of z -coordinates. x = linspace(1,50,10) y = linspace(500,1000,3) z = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10; 2, 4, 6, 8, 10, 12, 14, 16, 18, 20; 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] The x vector must have the same number of elements as the number of columns in the z vector and the y vector must have the same number of elements as the number of rows in the z vector The command mesh(x,y,z) creates the plot Notice that the x -axis varies from 0 to 50, with data plotted from 1 to 50

Surf Plots Surf plots are similar to mesh plots, but surf creates a three- dimensional colored surface instead of a mesh The colors vary with the value of z The surf command takes the same input as mesh : either a single input— For example: surf(z), in which case it uses the row and column indices as x – and y -coordinates—or three matrices The command surf(x,y,z) using the same data as for mesh creates the graph

Continued…. The shading scheme for surface plots is controlled with the shading command The default (shown in previous slide) is “faceted.” Interpolated shading can create interesting effects The plot(in next slide) is created by adding shading interp to the previous list of commands

Continued…. Flat shading without the grid is generated when shading flat is used

Continued…. The color scheme used in surface plots can be controlled with the colormap function For example: colormap(gray) forces a grayscale representation for surface plots This may be appropriate if you’ll be making black-and-white copies of your plots Other available colormaps are autumn bone hot spring colorcube hsv summer cool pink winter copper prism jet (default) flag white

Example A more complicated surface can be created by calculating the values of Z : x= [-2:0.2:2]; y= [-2:0.2:2]; [X,Y] = meshgrid(x,y); Z = X.*exp(-X.^2 - Y.^2); In the preceding code, the meshgrid function is used to create the two-dimensional matrices X and Y from the one-dimensional vectors x and y The values in Z are then calculated The following code plots the calculated values: subplot(2,2,1) mesh(X,Y,Z) title('Mesh Plot'), xlabel('x-axis'), ylabel('y-axis'), zlabel('z-axis') subplot(2,2,2) surf(X,Y,Z) title('Surface Plot'), xlabel('x-axis'), ylabel('y-axis'), zlabel('z-axis') Either the x, y vectors or the X, Y matrices can be used to defi ne the x – and y - axes.

Contour Plots Contour plots are two-dimensional representations of three- dimensional surfaces, much like the familiar contour maps used by many hikers The contour command was used to create Figure c, and the surfc command was used to create Figure d(in next slide) : subplot(2,2,3) contour(X,Y,Z) xlabel('x-axis'), ylabel('y-axis'), title('Contour Plot') subplot(2,2,4) surfc(X,Y,Z) xlabel('x-axis'), ylabel('y-axis') title('Combination Surface and Contour Plot')

Pseudo Color Plots Pseudo color plots are similar to contour plots, except that instead of lines outlining a specific contour, a two-dimensional shaded map is generated over a grid MATLAB includes a sample function called peaks that generates the x, y, and z matrices of an interesting surface that looks like a mountain range: [x,y,z] = peaks; With the following code, we can use this surface to demonstrate the use of pseudo color plotssubplot(2,2,1) pcolor(x,y,z) The grid is deleted when interpolated shading is used: subplot(2,2,2) pcolor(x,y,z) shading interp

Continued…. You can add contours to the image by overlaying a contour plot: subplot(2,2,3) pcolor(x,y,z) shading interp hold on contour(x,y,z,20,'k') The number 20 specifies that 20 contour lines are drawn, and the 'k' indicates that the lines should be black If we hadn’t specified black lines, they would have been the same color as the pseudo color plot and would have disappeared into the image Finally, a simple contour plot was added to the figure for comparison: subplot(2,2,4) contour(x,y,z)

Editing Plots From The Menu Bar In addition to controlling the way plots look by using MATLAB commands, plots can be edited after thses have created The plot in next slide was created with the sphere command, which is one of several sample functions, like peaks, used to demonstrate plotting sphere

Continued…. In the figure, the Insert menu has been selected Notice that you can insert labels, titles, legends, text boxes, and so on, all by using this menu The Tools menu allows you to change the way the plot looks, by zooming in or out, changing the aspect ratio, etc. The figure toolbar, underneath the menu toolbar, offers icons that allow you to do the same thing

Continued…. The plot in the previous slide doesn’t really look like a sphere; it’s also missing labels and a title, and the meaning of the colors may not be clear This plot can be edited by first adjusting the shape: Select Edit -> Axes Properties from the menu toolbar From the Property Editor—>Axes window, select More Properties -> Data Aspect Ratio Mode Set the mode to manual

Continued…. Similarly, labels, a title, and a color bar were added (figure shown in next slide) using the Property Editor They could also have been added by using the Insert menu option on the menu bar Editing plot in this manner is more interactive and allows to fine-tune the plot’s appearance The only problem with editing a figure interactively is that if MATLAB program is run again, and all improvements will be lost

Creating Plots from Workspace Window A great feature of MATLAB is its ability to create plots interactively from the workspace window In this window, select a variable, then select the drop-down menu on the plotting icon (shown in Figure in next slide ) MATLAB will list the plotting options it “thinks” are reasonable for the data stored in variable Simply select the appropriate option, and your plot is created in the current figure window If you don’t like any of the suggested types of plot, choose More plots from the drop-down menu, and a new window will open with the complete list of available plotting options for you to choose from This is especially useful, because it may suggest options that had not occurred For example: (figure in next slide) scatter plot of the x and y matrices highlighted in the figure. The matrices were created by loading the seamount data set, which is built into MATLAB

Continued…. If you want to plot more than one variable, highlight the first, then hold down the Ctrl key and select the additional variables To annotate plots, use the interactive editing process The interactive environment is a rich resource The more information is get out by exploring and experimenting