Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.

Slides:



Advertisements
Similar presentations
Excel Vocabulary.
Advertisements

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.
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 Chapter 4 Curve Plotting with MATLAB MATLAB provides some very powerful features for plotting and labeling curves. These operations can be performed.
Microsoft Office XP Microsoft Excel
Microsoft Word 2010 Lesson 1: Introduction to Word.
Microsoft ® Office Word 2007 Training Table of Contents II: Customize your TOC [Your company name] presents:
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.
FIRST COURSE Excel Tutorial 4 Working with Charts and Graphics.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
Using Excel for Data Analysis in CHM 161 Monique Wilhelm.
EGR106 Week 6 MATLAB FILES Two Dimensional Plots Multiple Plots
EGR106 Week 4 Two Dimensional Plots Multiple Plots Plot Formatting Homework.
COMPREHENSIVE Excel Tutorial 4 Working with Charts and Graphics.
Using Charts in a Presentation Lesson 6. Software Orientation Charts can help your audience understand relationships among numerical values. The figure.
Introduction to Excel 2007 Part 3: Bar Graphs and Histograms Psych 209.
NU Data Excel Orientation Graphing of Screening Data and Basic Graphing Functions.
An introduction to Plotting in MATLAB Rikard Johansson Department of Biomedical Engineering (IMT) Linköping University
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
© Ms. Masihi.  The Dreamweaver Welcome Screen first opens when you start Dreamweaver.  This screen gives you quick access to previously opened files,
C51BR Applications of Spreadsheets 1 Chapter 16 Getting Started Making Charts.
European Computer Driving Licence Syllabus version 5.0 Module 4 – Spreadsheets Chapter 22 – Functions Pass ECDL5 for Office 2007 Module 4 Spreadsheets.
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.
Examples of different formulas and their uses....
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
Microsoft ® Office Excel 2007 Working with Charts.
XP New Perspectives on Integrating Microsoft Office XP Tutorial 3 1 Integrating Microsoft Office XP Tutorial 3 – Integrating Word, Excel, Access, and PowerPoint.
Copyright 2006 South-Western/Thomson Learning Chapter 12 Tables.
Getting Started with TI-Interactive. TI-Interactive TI-Interactive can be used to create a variety of graphs. Scatter Plots, Line Plots, Histograms, Modified.
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,
1. Chapter 15 Creating Charts 3 Charting Data in Word A chart or graph presents data visually. A chart depicts numeric data in a graphical format. If.
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.
DAY 6: MICROSOFT EXCEL – CHAPTER 3 Sravanthi Lakkimsetty September 2, 2015.
Chapter 5 Working with Multiple Worksheets and Workbooks
Advanced Graphing Using Excel V.1 Part II: Giving your graph style Written and Created by: James Golen University of Michigan – Dearborn Science Learning.
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,
Excel 2007 Part (3) Dr. Susan Al Naqshbandi
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.
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
ENGR 1181 College of Engineering Engineering Education Innovation Center Excel Graphing.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
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.
Microsoft Excel Illustrated Introductory Workbooks and Preparing them for the Web Managing.
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.
Lecture 25.
INTRODUCTION TO SPREADSHEET APPLICATIONS
Lecture 25: Exploring data
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.
MATLAB How to use (using M-files)
Plotting Signals in MATLAB
Chapter 8 Using Document Collaboration and Integration Tools
Presentation transcript:

Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161

Plotting Large tables and reams of data are difficult to interpret. Graphing techniques facilitate seeing trends, picking out highs and lows, and serve as a quick check on one’s calculations. Most common plot is the x-y plot, i.e., a two dimensional plot. MATLAB is rich in both 2 and 3 dimensional graphing capabilities. We are going to study 2 dimensional plotting. We will also practice 3-D plotting in our second program project.

Plotting II When we complete the material in Chapter 5, we will be able to Create and label 2-dimensional plots. Adjust the appearance of your plots. Use our plots to interpret our results. Have a basis for studying more complex MATLAB graphical capabilities.

Basic Plotting Concepts In general, through calculations or experimental measurements, we have amassed data where y = f(x). We call x the independent variable and y the dependent variable. x and y are usually n dimensional vectors. Plotting is nothing more than a visual representation of the relationship between x and y.

Basic Plotting Concepts II The basic MATLAB plotting command is plot (x, y) The graph is generated in the MATLAB Graphics window and labeled as Figure 1 or 2, etc. Simple MATLAB commands allow you to label the x and y axes, label your graph, label legends, and format the graph as you want.

Basic Plotting Concepts III It is easy to plot multiple sets of data in a single graph, And to generate multiple graphs in a single Graphics Window. MATLAB calls these sub-plots.

Plotting Functions MATLAB supports a number of basic plotting functions in addition to the line chart. These include Bar Charts (vertical and horizontal, 3 dimensional) Pie Charts (2 and 3 dimensional) Histograms Semilog plots Loglog plots Polar plots

Plotting Commands The basic plotting command is plot (x, y) where x is the independent variable and y is the dependent variable. plot (x, y1, x, y2) will plot two lines in the graph (Note x is the same.) For Y = [y1;y2], plot (x, Y) will generate the same plot as above. When the dependent variable is a matrix, MATLAB plots each row of Y vs x. Another way to plot 2 lines on one graph is to use the “hold on” command plot (x,y1) hold on plot (x,y2) hold off Normally when MATLAB executes a plot command it erases the current figure and then plots anew. The command “hold on” suppresses the erase.

Plotting Commands II Labeling your graphs axes, and titling your chart is easy. Use the xlabel (‘....’) and the ylabel (‘....’) commands to label your axes appropriately. You must surround your labels in single quotes. Single quotes tell MATLAB that it is a character string. Use the title (‘....’) command to title the graph. Use the legend (‘line1’, ‘line2’, ‘line3’) command to identify a designator with each line on your graph. The order of the entries corresponds to the order that you plotted the lines. Or use the Insert Tab on the Graphics Window toolbar to customize your graph. NOTE: when you customize a graph interactively, i.e., using the Insert Tab, the next time you run the program, the customization is lost.

Plotting Commands III To open multiple figures use the figure (n) command, Figure 1 is the default window, but after using this window to plot in, enter the command figure (2) to create a new graphics window. The next time you plot, the 2 nd graphics window will be used thereby preserving the results graphed in figure 1. Both windows can be viewed as wanted. Don’t forget when in need of information about the plot command, enter help plot in the Command Window for information. Finally, the command plot (y) makes sense to MATLAB. Here MATLAB uses the indices of the vector y as the x values.

Plotting Commands IV The gtext command is another usual tool for adding text to a graph. Simply enter the gtext command in your program or in the Command Window as gtext(‘This string will display on the graph’) A crosshair will appear on the graph, position it appropriately and click the mouse to see the text added to the graph.

Line, Color and Mark Style You can select line type, point type, and color for each of your plotted lines. See page 157 of the text for Table 5.2 of the option codes to use. For example, plot (x,y, ‘:og’) will generate a dotted line, with a circle point type, and color green. Enter 1, 2 or 3 option codes in any order surrounded by single quotes to define the style you want to use with your line graph. The option codes need to immediately follow the x,y pair where they specify the style. When multiple lines are being plotted using a single plot command, follow each x,y pair with its option code in single quotes and separated by commas. When no option codes are present, MATLAB uses its default code, solid black line with no point type.

Axes Scaling Unless you choose to scale your axes, MATLAB will scale them automatically based upon the values in x and y. This is the easiest method. But, you can scale your axes with the axis (v) command where v = [xmin, xmax, ymin, ymax], that is, v is a 4 element row vector provided by you with the min and max values for each axes. The command axis without the argument v freezes the current axes scale for subsequent plots. Enter axis again to unfreeze.

Axes Scaling II Sometimes you will want to have two different vertical axes scaling, one on the left hand side of the graph and the other on the right hand side. To do this Use the plotyy (x, y1, x, y2) command to force MATLAB to scale the vertical axes independently for the two lines in your chart. Then use the Insert Tab in the graphics window to label the right hand vertical axis. The chart title, and x and left hand y axes labels can be added using the title, xlabel and ylabel commands. Only the right hand label needs to be added using the Insert Tab.

Subplots The subplot command allows you to split the graphics window into a number of sub-windows. You can choose two sub-windows arranged horizontally or vertically, or You can choose an array of sub-windows, say two rows with two columns or 4 subplots displayed at one time. More than 4 isn’t too practical. Things get too small.

Subplots II The subplot command is specified in the following manner, subplot (m,n,p) where m, n, and p are integers; m and n specify the size of the array of subplots and p specifies which subplot is being referenced. Subplots are numbered from left to right, top to bottom. subplot (2,2,3) would specify a 2 by 2 array of subplots with the 3 indicating the lower left hand plot in the array. To use this feature, you will do the following; >> subplot (2,1,1); % The subplot command proceeds >> plot (x,y)% the plot command. Here two subplots are specified, one over the other, the plot takes place in the upper chart.

Subplots III Chart titling, axes labeling, etc., following the plot command will refer to the last subplot indicated. Any additional plot commands will also refer to the last subplot indicated. To select a new sub-window to plot in, you have to select that sub-window with a subplot command before you use the plot (x,y) command. You can graph multiple x,y pairs in each subplot, select the style, add legends, etc., just as you have learned how to do with a single graph.

Plotting from the Workspace Window MATLAB 7 allows you to create plots from the Workspace window. This lets you view intermediate results or any variable in the Workspace window. In the Workspace window, select the variable you want to plot. If more than one, hold down the Ctrl key and select the additional ones that you want plotted. Next click on the “plotting icon”, the squiggly line in the the Workspace toolbar. MATLAB selects what it thinks would be good plotting options based upon the data. Select your graph type and the graph is generated. Use More plots to see a complete list of plot options.

Saving Plots Often you may want to save a plot to include in another document, for example a Word document for a project report. From the figure window, save the plot in a file using the jpeg format. The jpeg format is pretty universal and compatible with MicroSoft Word and Powerpoint applications. It’s easy to do, give it a try.

The fplot function I A very useful built in function to help visualize functions, y = f(x), is the fplot function. Consider the following example; suppose you want to see what the function y = 5sin 2 (t) + tcos 2 (t) looks like for –2π < t < +2π

The fplot function II Use the following MATLAB statement; fplot(‘5*sin(t)^2 + t*cos(t)^2’,[-2*pi, 2*pi]) to create the graph. Note the function we want to plot is enclosed in single quotations. fplot is a very useful function for Calculus, to help visualize functions of a single variable.

3_D plotting Our book provides you with the elements for 3-dimension plotting. We wont cover them explicitly but we get some experience with our second programming assignment this semester as it requires you to make a 3- dimensional plot. Go ahead and read through the remaining parts of the chapter to acquaint yourself with the key elements of 3-D plotting.

Chapter 5 Assignments Chapter 5 assignments let you practice plotting. They are, 5.11, 5.13, 5.20, 5.25, 5.27.