Matlab Project

advertisement
Name: Scott Trocchia
Class: SEAS 001 Lab Section 34
GTA: Tom Farmer and Qianyi Zhao
Project: Optimizing Range and Height of a Projectile Using Matlab
9/25/07
Q1. Vary the angle θ between 10 degrees and 90 degrees in steps of 2 degrees and
calculate the range ( R ) for an initial velocity of the cannon (vo = 5 m/s)
(note: is matlab using degrees or radians? Check help to find out.)
Matlab CODE:
a= pi/18:pi/90:pi/2;
R=(25*sin(2*a))./(9.8)
Matlab OUTPUT:
R=
Columns 1 through 7
0.8725
1.0376
1.1976
1.3518
1.4995
1.6398
1.7721
2.2092
2.2928
2.3653
2.4262
2.5495
2.5495
2.5370
2.5123
2.2928
2.2092
2.1149
2.0102
1.4995
1.3518
1.1976
1.0376
0.3550
0.1780
0.0000
Columns 8 through 14
1.8958
2.0102
2.1149
Columns 15 through 21
2.4752
2.5123
2.5370
Columns 22 through 28
2.4752
2.4262
2.3653
Columns 29 through 35
1.8958
1.7721
1.6398
Columns 36 through 41
0.8725
0.7032
0.5304
Interpretation: for each angle measure from pi/18 radians to pi/2 radians, in increments of
pi/90, there is a corresponding range or distance value.
Q2. Plot R vs. θ for vo = 5
Matlab CODE:
plot(theta,R)
xlabel('angle in radians')
ylabel('range of projectile')
title('Range of Projectile with initial velocity of 5 m/s')
Matlab OUTPUT:
Range of Projectile with initial velocity of 5 m/s
3
range of projectile in meters
2.5
2
1.5
1
0.5
0
0
0.2
0.4
0.6
0.8
1
angle in radians
1.2
1.4
1.6
Interpretation: for every angle measure at which the projectile is shot, there is a
corresponding distance that projectile will travel. At one of these angle measures, the
distance will be the greatest.
Q3. Find the maximum range (R) from the data/graph generated.
Matlab CODE:
max(R)
Matlab OUTPUT:
ans =
2.5495
Interpretation: the greatest distance, or range, the projectile will travel is 2.5495 meters.
Q4. Repeat questions 1, 2 and 3 by calculating H and plot H vs. θ for vo = 5m/s
Matlab CODE:
theta= pi/18:pi/90:pi/2;
H= (25*(sin(theta)).^2)/(19.6)
Matlab OUTPUT:
H=
Columns 1 through 7
0.0385
0.0551
0.0747
0.0969
0.1218
0.1492
0.1790
0.3189
0.3582
0.3988
0.4407
0.6155
0.6600
0.7044
0.7485
0.9173
0.9566
0.9944
1.0304
1.1537
1.1786
1.2009
1.2204
1.2693
1.2740
1.2755
Columns 8 through 14
0.2110
0.2451
0.2811
Columns 15 through 21
0.4835
0.5270
0.5711
Columns 22 through 28
0.7920
0.8348
0.8767
Columns 29 through 35
1.0645
1.0965
1.1263
Columns 36 through 41
1.2370
1.2508
1.2616
Interpretation: each angle measure in radians gives a corresponding height.
Matlab CODE:
plot(theta,H)
xlabel('angle in radians')
ylabel('height of projectile in meters')
title('Height of Projectile with initial velocity of 5 m/s')
Matlab OUTPUT:
Height of Projectile with initial velocity of 5 m/s
1.4
height of projectile in meters
1.2
1
0.8
0.6
0.4
0.2
0
0
0.2
0.4
0.6
0.8
1
angle in radians
1.2
1.4
1.6
Interpretation: each radian value corresponds to a different height that the projectile will
attain.
Matlab CODE:
max(H)
Matlab OUTPUT:
ans =
1.2755
Interpretation: the greatest height the projectile will reach based on a single angle
measure in radians is 1.2755 meters.
Download