Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

Introduction to Graphing in M-File Environments

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

EXAMPLE 1

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

NOTE: 

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.
TABLE 1: Dodge Viper Stopping Data
Distance (ft)Velocity (ft/s)
0102.7
29.192.4
55.182.1
78.071.9
97.961.6
114.751.3
128.541.1
139.230.8
146.920.5
151.510.3
153.00.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)
Figure 1 shows the graph created by these commands.
Figure 1: Graph of the Viper's velocity as a function of distance.
Figure 1 (Viper.png)
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 Figure 2.
Figure 2: Graph of the Viper's velocity as a function of distance. The graph has a title and labels on the axes.
Figure 2 (Viper2.png)
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.

MATLAB, WORD, AND WINDOWS: 

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.

EXERCISE 1

Repeat Example 1 using the following data for a Hummer H2:

NOTE: 

As in Example 1, this data was not measured; it was computed using the stopping distance reported for a Hummer H2 and assuming constant deceleration.
TABLE 2: Hummer H2 Stopping Data
Distance (ft)Velocity (ft/s)
0102.7
46.392.4
87.882.1
124.471.9
156.161.6
182.951.3
204.941.1
222.030.8
234.220.5
241.510.3
244.00.0

EXAMPLE 2

An m-file environment can also be used to plot functions. For example, the following commands plot cos(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)')
Figure 4 shows the graph created by these commands.
Figure 4: Graph of one period of the cosine function.
Figure 4 (Cos.png)

EXERCISE 2

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.

EXERCISE 3

In electrical circuit analysis, the equivalent resistance Req of the parallel combination of two resistors R1 and R2 is given by the equation
Req=
1
1
R1
+
1
R2
(1)
Set R2=1000 Ohms and plot Req for values of R1 from 100 Ohms to 3000 Ohms.

EXERCISE 4

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:
TABLE 3: Height and Time Data
Time (s)Height (in)
0.030022.0
0.063321.5
0.096720.5
0.130018.8
0.163317.0
0.196714.5
0.230012.0
0.26338.0
0.29673.0
This experimental data is to be compared to the theoretically expected values given by the following equation:
h=22 in
1
2
 
gt2
(2)
where h is in inches, t is in seconds, and g=386.4
in
s2
 
. 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.

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.