1 Chapter 4 Curve Plotting with MATLAB MATLAB provides some very powerful features for plotting and labeling curves. These operations can be performed.

Slides:



Advertisements
Similar presentations
Lecture 5.
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.
1 Chapter 13 Curve Fitting and Correlation This chapter will be concerned primarily with two separate but closely interrelated processes: (1) the fitting.
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.
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.
Excel Part I Basics and Simple Plotting Section 008 Fall 2013 EGR 105 Foundations of Engineering I.
1.3 ARRAYS, FILES, AND PLOTS + FOURIER SERIES BY MR. Q.
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.
Engineering Fundamentals and Problem Solving, 6e Chapter 5 Representation of Technical Information.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Matlab intro The Environment
MATLAB Fundamentals.
P 251 Laboratory Activity II Graphical Analysis I.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Chapter 5 Common Functions and their Properties
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
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,
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
V. Rouillard  Introduction to measurement and statistical analysis GRAPHICAL PRESENTATION OF EXPERIMENTAL DATA It is nearly always the case that.
Chapter 13 The Math for Graphing in DC Circuits. Graphing Overview  Critical for practical analysis many different natural systems. Note: Theoretical.
Kinematics Velocity and Acceleration. Motion Change in position of object in relation to things that are considered stationary Usually earth is considered.
Projectile Motion Previously, we studied motion in one direction (linear motion) Projectiles follow a curved path (nonlinear motion) The velocity of a.
Chapter 2 Motion in One Dimension. Kinematics Describes motion while ignoring the external agents that might have caused or modified the motion For now,
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.
Unit 1, Chapter 2 Integrated Science. Unit One: Forces and Motion 2.1 Using a Scientific Model to Predict Speed 2.2 Position and Time 2.3 Acceleration.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
Bar Graphs Used for comparing separate groups. Axes X- axis: independent variable (what the scientist controls) Horizontal D – dependent R – responding.
Graph: a visual display of information or data
Mathematical Model of Motion Chapter 5. Velocity Equations Average velocity: v =  d/  t To find the distance traveled with constant or average velocity.
Section 1.1 Rectangular Coordinates; Graphing Utilities; Introduction to Graphing Equations.
GRAPHING AND RELATIONSHIPS. GRAPHING AND VARIABLES Identifying Variables A variable is any factor that might affect the behavior of an experimental setup.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
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-d Arrays & Plotting.
Graphing Most people at one time or another during their careers will have to interpret data presented in graphical form. This means of presenting.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 2 in MATLAB Topics Covered: 1.More about 2-D plots  Placing multiple.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
GRAPHING NOTES Understanding and constructing graphs.
1.4 Graphs for Quantitative Data Chapter 1 (Page 17)
CS100A, Fall 1998, Lecture 191 CS100A, Fall 1998 Lecture 19, Thursday Nov 05 Matlab Concepts: Matlab arrays Matlab subscripting Matlab plotting.
Chapter 3 Section 3.3 Linear Functions: Graphs and Applications.
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.
Plotting in Excel Ken youssefi Engineering 10.
Plotting in Excel KY San Jose State University Engineering 10.
Copyright © Cengage Learning. All rights reserved.
Accurate horizontal and vertical scales chosen. The independent variable is shown on the horizontal (across) axis. The dependent variable is.
Graphing Data.
Two-Dimensional Plots
Tell a Story with the Data
Chapter 11.2 Graphs are a visual representation of trends in data.
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.
Graphing Data.
Cost-Revenue Analysis Break-Even Points
Presentation transcript:

1 Chapter 4 Curve Plotting with MATLAB MATLAB provides some very powerful features for plotting and labeling curves. These operations can be performed as part of an overall mathematical analysis, or experimental data may be provided to the program for the primary purpose of plotting. Curves obtained from MATLAB plots can be exported to other programs for presentation purposes.

2 MATLAB has the capability to generate plots of many types. This includes linear plots, line plots, logarithmic plots on both scales, logarithmic plots on one scale, stem plots, bar graphs, and three- dimensional plots. We will be using these capabilities throughout the text, so the present development is intended as an introduction, with many operations to follow in later chapters.

3 Vector Lengths A very important fact that should be emphasized at the outset is that to plot one vector against another, the vectors must have the same number of elements. One can plot either a column vector or a row vector versus either a column vector or a row vector provided they have the same number of values.

4 Different Vector Lengths If the vectors have different lengths, it is possible to use a portion of the longer one as one of the variables. For example, suppose y has 200 values and x has 120 values. One could define y1 by the following command: >> y1 = y(1:120) The variable y1 now has the same number of points as x and the two could be plotted together.

5 The Variables x and y In the two-dimensional plotting commands, the horizontal axis will be referred to as the x-axis and the vertical axis will be referred to as the y-axis. However, the actual variables can be labeled with any quantities. It is only in the plot commands that x and y are used.

6 Creating a Linear Array Whenever a plot is to be created from an equation, and linear plots for both the dependent and independent variables are desired, the most convenient way to achieve the result is to create a linear array or vector for the values of the independent variable. MATLAB offers a number of different commands that can be used for this purpose. For this explanation, assume that the independent variable is x.

7 Command for Linear Array >> x = x1:xstep:x2 where x1=beginning point, x2=final point, and xstep=step size. Assuming that the final point coincides with an integer multiple of xstep, the number of points N is

8 Alternate Command for Linear Array >> x = linspace(x1, x2, N) where x1=beginning point, x2=final point, and N=number of points. The name linspace represents “linear spacing”. Again, the number of points N is

9 Example 4-1. When air resistance can be ignored, the velocity (in m/s) of an object falling from rest is Use MATLAB to plot the velocity over a time interval from 0 to 10 s.

10 Example 4-1. Continuation. It should be emphasized that this is a simple linear equation with a vertical intercept of 0 so we actually need only two points to plot the curve. However, our purpose is to learn how to use MATLAB for plotting and we will utilize far more points than necessary as a learning process.

11 Example 4-1. Continuation. A time step of 0.1 s will be selected. >> t = 0:0.1:10; Alternately, >> t = linspace(0,10,101);

12 Example 4-1. Continuation. We can inspect various values of t. >> t(1:5) ans =

13 Example 4-1. Continuation. >> v = 9.8*t; This command generates 101 values of v corresponding to the 101 values of t. It can be plotted by the command >> plot(t, v) The result is a “raw” plot but various labels can be added as will be shown on the next slide.

14

15 Example 4-1. Continuation. A horizontal label is provided. >> xlabel(‘Time, seconds’) A vertical label is provided. >> ylabel(‘Velocity, meters/second’) A title is provided. >> title(‘Figure 4-3. Velocity of falling object of Example 4-1 with grid.’) A grid is added. >> grid

16

17 Example 4-2. A force in newtons (N) is given below. Plot the function. Assume 101-point t vector is in memory. >> f1 = 0.25*t.*t; or >> f1 = 0.25*t.^2: >> plot(t, f1) >> xlabel(‘Time, seconds’) >> ylabel(‘Force, newtons’) >> title(‘Figure 4-4. Force as a function of time in Example 4-2.’) >> grid

18

19 Example 4-3. A force in newtons (N) is given below. Plot the function. Assume 101-point t-vector is in memory. >> f2 = *t.^2; >> plot(t, f2) >> xlabel(‘Time, seconds’) >> ylabel(‘Force, newtons’) >> title(‘Figure 4-6. Second force as initially obtained in Example 4-3.’) >> grid

20

21 Example 4-3. Continuation. Plot is modified by the command >> axis([ ])

22

23 Multiple Plots on Same Graph The two functions f 1 and f 2 of the previous two examples can be plotted on the same graph by the command >> plot(t, f1, t, f2) The command gtext(‘label’) allows a label to placed on a graph using crosshairs. The resulting functions are shown on the next slide.

24

25 Log-Log Plots

26 Example 4-5. Plot the 2nd degree function below on a log-log graph. >> x = logspace(-1, 1, 100); >> y = x.^2; >> loglog(x, y) A grid and additional labeling were provided and the curve is shown on the next slide.

27

28 Bar and Stem Plots Command for a bar plot: >> bar (x, y) Command for a stem plot: >> stem (x, y)

29 Example 4-6. The text contains the sales in thousands of dollars for a small business from 1993 through Construct a bar graph. >> year = 1993:2002; >> sales = [ the 10 values in the text]; >> bar(year, sales) The graph with additional labeling is shown on the next slide.

30

31 Example 4-7. Plot the data of the previous example using a stem plot. Assume that the variables year and sales are still in memory. The command is >> stem (year, sales) The plot with additional labeling is shown on the next slide.

32