0 Up votes0 Down votes

5 views32 pagesMar 27, 2014

© © All Rights Reserved

PPT, PDF, TXT or read online from Scribd

© All Rights Reserved

5 views

© All Rights Reserved

- Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
- Hidden Figures Young Readers' Edition
- The Law of Explosive Growth: Lesson 20 from The 21 Irrefutable Laws of Leadership
- The E-Myth Revisited: Why Most Small Businesses Don't Work and
- The Wright Brothers
- The Power of Discipline: 7 Ways it Can Change Your Life
- The Other Einstein: A Novel
- The Kiss Quotient: A Novel
- State of Fear
- State of Fear
- The 10X Rule: The Only Difference Between Success and Failure
- Being Wrong: Adventures in the Margin of Error
- Algorithms to Live By: The Computer Science of Human Decisions
- The Black Swan
- Prince Caspian
- The Art of Thinking Clearly
- A Mind for Numbers: How to Excel at Math and Science Even If You Flunked Algebra
- The Last Battle
- The 6th Extinction
- HBR's 10 Must Reads on Strategy (including featured article "What Is Strategy?" by Michael E. Porter)

You are on page 1of 32

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.

1

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 threedimensional 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.

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.

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.

4

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.

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.

6

>> 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

x2 x1 N 1 xstep

7

>> 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

x2 x1 N 1 xstep

8

Example 4-1. When air resistance can be ignored, the velocity (in m/s) of an object falling from rest is

v 9.8t

Use MATLAB to plot the velocity over a time interval from 0 to 10 s.

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.

10

>> t = 0:0.1:10; Alternately,

>> t = linspace(0,10,101);

11

>> t(1:5)

ans = 0 0.1000 0.4000 0.2000 0.3000

12

>> 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.

13

14

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

15

16

Example 4-2. A force in newtons (N) is given below. Plot the function. 2 f1 (t ) 0.25t

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.) 17 >> grid

18

Example 4-3. A force in newtons (N) is given below. Plot the function.

f 2 (t ) 25 0.25t

Assume 101-point t-vector is in memory. >> f2 = 25+0.25*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

19

20

Plot is modified by the command

>> axis([0 10 0 50])

21

22

The two functions f1 and f2 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.

23

24

Log-Log Plots

y Cx

k

y mx b

' '

'

25

Example 4-5. Plot the 2nd degree function below on a log-log graph.

yx

>> 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.

26

27

Command for a bar plot: >> bar (x, y) Command for a stem plot:

>> stem (x, y)

28

Example 4-6. The text contains the sales in thousands of dollars for a small business from 1993 through 2002. 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.

29

30

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.

31

32

- Statics HandoutUploaded byrj2263
- Algebra 2_Big Ideas Math_student Journal AnswersUploaded byMOED
- 30 - ITEMS ANALYSIS - Competency analysis Template-final.xlsxUploaded byMica Skywalker
- LinearCalibration_v1Uploaded byRosmer Mijares
- MAT 1033 SyllabusUploaded byEdison Fye
- Anti SubstanceUploaded byjavad
- Tips 4 r Mcc IntegersUploaded byyddap11
- AP Curriculum GuideUploaded byFerlinda Anor
- 3Uploaded byshivam12365
- Introduction VectorsUploaded byJess Sz
- Homework 1 SolutionsUploaded bychellebodnar
- ppt linear equations in 2 variables.pptxUploaded bySaleema Hussain
- Algebra 1. [Electronic Resource] Concepts and SkillsUploaded byginotrucheli
- ForecastingUploaded byJai Deep
- 2 Bhaskar RaoUploaded byLily Suherlina Ahmad
- adv algebra unit 2Uploaded byapi-264152935
- VECTORSUploaded byasep
- Control System - Lesson Plan Practical 6Uploaded bymohdzaini807646
- Unit1StudentNotesSP2012-3Uploaded byErin Wilson
- High School Physics eBookUploaded byB Pierce
- Basna Paper ID ICCIET454 Pranav K. Jani (1)Uploaded byFaouzi Tlemcen
- mid-term reviewUploaded byapi-245317729
- Programming With MATLABUploaded bykamal
- 3 Robotic Systems KinematicsUploaded byAdam Mahmood
- Apostila CEESVO Elementary School - Math 2004Uploaded by4gen_5
- Physics TipsUploaded byAbbas Haider
- yyyyUploaded byArjun
- New in STOAT 4.1.pdfUploaded byJose Villegas
- tras_manUploaded byantenas87
- PDMS Equi Guide v02_English Version _EngUploaded byRaymond Metselaar

- FESTO Hydraulics CourseUploaded bymadmax2222
- WPS (Flare)Uploaded byاحمد عقل
- W.P.S(super duplex)Uploaded byاحمد عقل
- Murex Filler Metal Selection GuideUploaded byJUAN VASCO
- Principle of Hydraulic System DesignUploaded bykwameh
- Festo Basic PneumaticUploaded byshellafaye
- Catalogos SMAW.pdfUploaded byJUAN VASCO
- WPS ListUploaded byاحمد عقل
- Electroneumatica_FestoUploaded byRenzo Delgado
- Module 7 Manual ICDLUploaded byاحمد عقل
- soldaduraUploaded byWilliam Fernando Reatiga
- Proposed Welding Procedure No.gupcO PMS SAQ QC 0001Uploaded byاحمد عقل
- Lincolin-smaw Outershield ElectrodesUploaded byاحمد عقل
- Catalogo OuthershieldUploaded byJUAN VASCO
- S290DEUploaded byاحمد عقل
- S690DEUploaded byاحمد عقل
- S290_Info_EUploaded byاحمد عقل
- S000DE_2010Uploaded byاحمد عقل
- Electrohydraulics Basic LevelUploaded bySavio Fernandes
- Module 5 Manual ICDLUploaded byاحمد عقل
- Module 6 Manual ICDLUploaded byاحمد عقل
- Module 2 Manual ICDLUploaded byاحمد عقل
- Module 3 Manual ICDLUploaded byاحمد عقل
- Module 4 Manual ICDLUploaded byاحمد عقل
- Module 1 ManualUploaded byRachid Inf
- centrifugal pumpUploaded byVivek Mishra
- Fluid Mechanics InstractionalUploaded byRodrigo
- Chapter 3Uploaded byاحمد عقل
- pptUploaded byWalid_Atef_3704
- fluid power technologyUploaded byMelvin Victor DE Poures

- Part 1Uploaded byLata Sharma
- Flow Wizard Rotating Turb Flow Mixing TankUploaded bySatish Kumar Bonthu
- Vectors ENES102Uploaded byTheAzn
- CSI Analysis Reference.pdfUploaded byg1g1ng
- Part Test 1 - 21102018Uploaded bybE SpAciAl
- Homework 8 ProblemsUploaded byHân Bảo
- Dietmar Gross, Wolfgang Ehlers, Peter Wriggers, Jörg Schröder, Ralf Müller-Statics - Formulas and Problems_ Engineering Mechanics 1-Springer-Verlag (2017).pdfUploaded byĐào Hải Nam
- PS3Uploaded byMachodog
- Aero (1)Uploaded byrajavel777
- Dynamics - Chapter 16 [Beer7]Uploaded byapi-3709496
- 1. Rectilinear Kinematics.pdfUploaded byDaniel Naoe Festin
- Dynamics Tutorial 8-Balancing of rotating bodies-12p.pdfUploaded bymanfredm6435
- Manual Mt3dmsUploaded byramondiazn
- 2017 MidtermUploaded byThapelo Sebolai
- bkc19.pdfUploaded byrohitrgt4u
- 9709_w03_msUploaded bymichael heng
- composite materialsUploaded bySushant Patil
- CalcIII CompleteUploaded bypalagana
- Chapter7 Calculus)Uploaded byMichael Watson
- Blinn - Clipping Using Homogeneous Coordinates.pdfUploaded byMark
- physicsUploaded byAyam Mas
- Physics ReviewerUploaded byBj Larracas
- Btech BarchUploaded byac
- Vector AlgebraUploaded byKuntal Satpathi
- Chapter 01Uploaded byJoseph William Gallardo
- Electromagnetics and OpticsUploaded byChacko Mathew
- Applied Mathematics.pdfUploaded byAkshay J
- scm_11-01-2005.pdfUploaded byDavid
- Unit 6 - Not MarkedUploaded byMitch Clark
- 2VA-N5.pdfUploaded byKendid Mahmudi

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.