MATLAB Chapter 3 Problems

advertisement
Engineering 161
Fall 2006
Some Programming Examples
Problem 3.2
In this problem, you are asked to calculate the range of a ballistic projectile as a function
if its initial velocity and the angle to the projectile from the horizon, from 0 to 90 degrees.
Consider the following program that illustrates a solution to this problem.
% Range of a Ballistic Projectile; range = v^2/g*sin(2*angle)
% Problem 3.2
% theta = angle from the horizon in degrees
% R = range; v = initial velocity in m/s
% Joe Mixsell
September 2006
%
theta = 0:0.5:90;
% angle in degrees
theta_radians = theta*pi/180;
% convert to radians
v = 50;
% initial velocity of 50 m/s
g = 9.9;
% accel due to gravity in m/s^2
R = ((v^2)/g)*sin(2*theta_radians);
[max_range, index] = max(R);
max_range
angle = 0.5*index
% angle for max distance
plot(theta, R);
hold on
%
% Second case, now with v = 100 m/s
%
v = 100;
R = ((v^2)/g)*sin(2*theta_radians);
[max_range, index] = max(R);
max_range
angle = 0.5*index
% angle for max distance
plot(theta, R)
save as Ballistic_Projectile in your MATLAB folder.
1
Problem 3.5
In this problem, you are to create a table of chemical reaction rates proportional to the
constant k given by the relationship
k = k0e-Q/RT
where Q = 8000 cal/mole
R = 1.987 cal/mole K
k0 = 1200 min-1
for temperatures T ranging from 100K to 500K in 50 degree increments.
% Create a table of chemical reaction rates vs Temperature T where
% k = k0*exp(-Q/RT)
% Problem 3.5
% Joe Mixsell
September 2006
%
% Define the constants
%
Q = 8000;
% cal/mole
R = 1.987;
% cal/mole K
k0 = 1200;
% min^-1
%
T = 100:50:500;
% range of temperatures in degrees K
k = k0*exp(-Q./(R*T));
% compute reaction rates
%
[T’, k’]
% create table of T and k
save as Reaction_Rates in your MATLAB folder
2
Problem 3.6
In this problem, the vector G represents the distribution of final grade scores. Compute
the mean, median, and standard deviation of G. Also use MATLAB to determine the
number of grades in the list.
% Determine a number of statistics of a list of final scores
% Grades are stored in an row vector called G
% Compute the mean, median and standard deviation and determine the number of
% scores in the list
% Problem 3.6
% Joe Mixsell
September 2006
%
clc, clear;
G = [ 68,83,61,70,75,82,57,5,76,85,62,71,96,78,76,68,72,75,83,93] ;
% Scores
%
mean_value = mean(G)
% compute the mean value
median_value = median(G)
% compute the median value
standard_deviation = std(G)
% compute the standard deviation
%
number_of_scores = length(G)
% determine number scores
save as Scores in your MATLAB folder
3
Download