<< Chapter < Page Chapter >> Page >
This module provides a tutorial introduction to graphing data in m-file environments.

One of the reasons that m-file environments are extensively used by engineers is their capability to provide graphical representations of data and computed values. In this module, we introduced the basics of graphing data in m-file environments through a series of examples. This module uses some fundamental operations on vectors that are explained in Vectors and Arrays in M-File Environments .

The table below shows speed as a function of distance for a braking Dodge Viper decelerating from 70MPH to 0MPH.

This data was not measured; it was computed using the stopping distance reported for a Dodge Viper and assuming constant deceleration. Thus, it may not accurately reflect the braking characteristics of a real Dodge Viper.
Dodge viper stopping data
Distance (ft) Velocity (ft/s)
0 102.7
29.1 92.4
55.1 82.1
78.0 71.9
97.9 61.6
114.7 51.3
128.5 41.1
139.2 30.8
146.9 20.5
151.5 10.3
153.0 0.0
The following commands will create a graph of velocity as a function of distance: dist = [0 29.1 55.1 78.0 97.9 114.7 128.5 139.2 146.9 151.5 153.0] vel = [102.7 92.4 82.1 71.9 61.6 51.3 41.1 30.8 20.5 10.3 0.0]plot(dist,vel) shows the graph created by these commands.
Graph of the Viper's velocity as a function of distance.
This graph shows the data, but violates several important conventions of engineering practice. The axes are not labeled with quantity and units, and the graph does not have a title. The following commands, when executed after the plot command, will label the axes and place a title on the graph. xlabel('Distance (ft)') ylabel('Velocity (ft/s)')title('Velocity vs Distance for the Dodge Viper') The results of these commands are shown in .
Graph of the Viper's velocity as a function of distance. The graph has a title and labels on the axes.

Got questions? Get instant answers now!

After creating a figure, you may wish to insert it into a document. The method to do this depends on the m-file environment, the document editor and the operating system you are using.

To paste a figure into a Word document on Windows, pull down the Edit menu of the window of the MATLAB figure you wish to paste, and select Copy Figure . Then go to the Word document into which you wish to insert the figure and use the paste command.

Repeat using the following data for a Hummer H2:

As in , this data was not measured; it was computed using the stopping distance reported for a Hummer H2 and assuming constant deceleration.
Hummer h2 stopping data
Distance (ft) Velocity (ft/s)
0 102.7
46.3 92.4
87.8 82.1
124.4 71.9
156.1 61.6
182.9 51.3
204.9 41.1
222.0 30.8
234.2 20.5
241.5 10.3
244.0 0.0

shows the graph of the Hummer H2 stopping data.

Graph of the H2 velocity as a function of distance.

Got questions? Get instant answers now!

An m-file environment can also be used to plot functions. For example, the following commands plot x over one period. x = 0:0.1:2*pi; y=cos(x)plot(x,y) xlabel('x')ylabel('cos(x)') title('Plot of cos(x)') shows the graph created by these commands.

Graph of one period of the cosine function.
Got questions? Get instant answers now!

The module Exercises for Basic Mathematical Operations describes how to compute the terminal velocity of a falling sky diver. Plot the terminal velocity as a function of the sky diver's weight; use weights from 40kg to 500kg.

Got questions? Get instant answers now!

In electrical circuit analysis, the equivalent resistance R eq of the parallel combination of two resistors R 1 and R 2 is given by the equation

R eq 1 1 R 1 1 R 2
Set R 2 1000 Ohms and plot R eq for values of R 1 from 100 Ohms to 3000 Ohms.

Got questions? Get instant answers now!

In an experiment, a small steel ball is dropped and videoed against a checkered background. The video sequence is analyzed to determine the height of the ball as a function of time to give the data in the following table:

Height and time data
Time (s) Height (in)
0.0300 22.0
0.0633 21.5
0.0967 20.5
0.1300 18.8
0.1633 17.0
0.1967 14.5
0.2300 12.0
0.2633 8.0
0.2967 3.0
This experimental data is to be compared to the theoretically expected values given by the following equation:
h 22 in 1 2 g t 2
where h is in inches, t is in seconds, and g 386.4 in s 2 . Create a graph that compares the measured data with the theoretically expected values; your graph should conform to good conventions for engineering graphics. Plot the measured data using red circles , and plot the theoretically expected values using a blue line .

Got questions? Get instant answers now!

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Freshman engineering problem solving with matlab. OpenStax CNX. Apr 23, 2007 Download for free at http://cnx.org/content/col10325/1.18
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Freshman engineering problem solving with matlab' conversation and receive update notifications?

Ask