Você está na página 1de 7

ENED 1090: Engineering Models I

Homework Assignment #1
Due: Week of September 8th at the beginning of your Recitation Section
Instructions:
1. Before you begin editing this document, you must save this document to your laptop or
you will end up losing all of your work. If you opened this document directly from
Blackboard, click on the Enable Editing button then choose File Save As and save the
document to your laptop. You should set up a folder on your laptop for ENED1090
where you keep all of your homework assignments and lab reports.
2. It is fine to work with other students, but what you turn in must be your own work - not
something copied from someone else.
3. Submit an electronic copy of your work to your individual section of Blackboard look
for Homework #1. Include your completed .docx file (pdf O.K. too) and your script file.
Note: You can attach more than one document in a single submission. Once you hit
submit, be patient and wait attachments take a while to upload. Hitting submit
multiple times will result in multiple submissions.
Problem 1: 1-d Arrays (Vectors)
(a) Use the Start:Inc:Max method to create a variable called t1 which is a vector of values
starting at 0, incrementing by 0.2, and ending at 1.2. Paste your MATLAB command and
result below.
MATLAB Command & Result: t1=0:0.2:1.2
Result: t1 =
Columns 1 through 4
0

0.2000

0.4000

0.6000

Columns 5 through 7
0.8000

1.0000

1.2000

(b) Use the linspace command to create a variable called t2 which is a vector of 10 equally
spaced values starting at 0 and ending at 14. Paste your MATLAB command and result
below.
MATLAB Command & Result: t2=linspace(0,14,10)
Result: t2 =
Columns 1 through 4
0

1.5556

3.1111 4.6667

Columns 5 through 8
6.2222

7.7778

9.3333 10.8889

Columns 9 through 10
12.4444 14.0000
You will need your vector, t1, from part (a) for the rest of this problem. If you have cleared it,
re-create it. Run each of the following commands in the command window leaving the
semicolon off as indicated. Paste the result into the space indicated and explain in your own
words what each of these commands do.
(c) EDU>> t1
t1 =

Result and Explanation?

Columns 1 through 4
0

0.2000

0.4000

0.6000

Columns 5 through 7
0.8000
1.0000
1.2000
This shows the variable, t1, which is a row vector from 0 to
1.2 and has an increasing increment of 0.2
(d) EDU>> t1(1)
ans =

Result and Explanation?

0
This shows that the value of t1 in the first position, which
is row 1, is 0
(e) EDU>> t1(5)
ans =

Result and Explanation?

0.8000
This shows that the value of t1 in the fifth position, which
is row 5, is 0.800
(f) EDU>> t1(8) Result and Explanation?
Index exceeds matrix dimensions.
This result appears because there are only 7 values for the
variable, t1 due to the minimum of 0, the maximum of 1.2, and
the increment of 0.2
(g)

EDU>> length(t1) Result and Explanation?

ans =
7
This command shows that the length of the row vector, t1, is 7
values. This means there are 7 values total in the one row
that composes t1 with one value in each column.
(h) EDU>> t1(1) = 42 Result and Explanation?
t1 =
Columns 1 through 4
42.0000

0.2000

0.4000

0.6000

Columns 5 through 7
0.8000
1.0000
1.2000
This changes the value of the first point of the vector, t1 to
equal 42 instead of 0 while the other values of t1 remain the
same as previously defined.
(i) EDU>> t1(5) = 73 Result and Explanation?
t1 =
Columns 1 through 4
42.0000

0.2000

0.4000

0.6000

Columns 5 through 7
73.0000
1.0000
1.2000
This changes the value of the fifth point of the vector, t1 to
equal 73 instead of 0.8 while the other values of t1 remain the
same as previously defined.

Problem 2: Plotting Functions


(a) Open a new script file and add a comment line at the top with your name, your section
number for Engineering Models I, and your professors name.
(b) Insert a new section and label it: %% Homework 1: Problem 2
(c) Within your script file, use the subplot command to break the MATLAB figure window into
a 3x1 grid of sub-windows. Then plot the following functions using MATLAB commands.
Use the 3rd input argument in the plot function (not Plot Tools) for the formatting.

Top Sub-window: y = t2 5*t + 2 (solid black line dont mark the data points
include grid). Label the x-axis as time (s) and add a title.
Middle Sub-window: y = e0.2t (dashed red line dont mark the data points
include grid). Label the x-axis as time (s) and add a title.
Bottom Sub-window: y = sin(10t)*sin(2(50t)) (solid blue line use t = 0 to 0.5
dont mark the data points). Label the x-axis as time (s) and add a title.

Note: Be sure to make good choices for the values on the x-axis. You will need a different
set of x-axis values for each function since they are all very different from one another.
(d) Run this section of your script and paste your MATLAB commands and resulting plot in the
space indicated below.
Paste MATLAB commands from your script file here:
%% Homework 1: Problem 2
t=0:0.001:5;
y1=(t.^2)-(5*t)+2;
subplot(3,1,1);
plot(t,y1,'k-');
xlabel('time (s)');title('y=t^2-5*t+2');grid;
t2=0:0.001:10;
y2=exp(t2*(-0.2));
subplot(3,1,2);
plot(t2,y2,'r--');
xlabel('time (s)');title('y=exp(-0.2*t)');grid;
t3=0:0.001:0.5;
y3=sin(10*pi*t3).*(sin(100*pi*t3));
subplot(3,1,3);
plot(t3,y3,'b-');
xlabel('time (s)');title('y3=sin(10*pi*t)*sin(100*pi*t)');

Paste plot here:


y=t 2-5*t+2

5
0
-5

0.5

1.5

0.05

0.1

0.15

2.5
3
time (s)
y=exp(-0.2*t)

3.5

4.5

10

0.4

0.45

0.5

0.5
0

5
6
7
time (s)
y3=sin(10*pi*t)*sin(100*pi*t)

0
-1

0.2

0.25
0.3
time (s)

0.35

Problem 3: (Based on Lab 2 Exercise)


Stopping sight distance is the distance that a driver must be able to see in order to be able to
come to a complete stop in the event of a hazard in the road. The equation for stopping sight
distance is:
( 0.278 V )2
S=
+0.278 V tr
19.6( f G)
S
V
f
G
tr
+

Stopping sight distance (m)


Vehicle speed (km/h)
Coefficient of friction
% Grade divided by 100
Reaction time (s)
Use + for uphill and for downhill

(a) Insert a new section in your script file and label it: %% Homework 1: Problem 3
(b) Create the following variables:
G = 0.01
tr = 2

(c) Create a vector, V_mph, that starts at 0, increments by 0.1, and ends at 80. Vector V_mph is
a vector of vehicle speeds in units of mph.
(d) Calculate a vector, V, that converts all of the velocity values in vector V_mph to velocity
values in the units of km/h.
(e) Assume the driver is going downhill and the coefficient of friction is f = 0.7 (dry road, decent
tires). Calculate the stopping sight distance for each of the values in vector, V, and save them
in a vector.
(f) Repeat Step 4 assuming the driver is going downhill and the coefficient of friction is f = 0.4
(wet road, decent tires).
(g) Repeat Step 4 assuming the driver is going downhill and the coefficient of friction is f = 0.1
(icy road, decent tires).
(h) Convert each of your vectors for stopping sight distance from units of meters to units of feet.
(i) Plot all three graphs in the same plot window with V_mph on the x-axis and Stopping Sight
Distances on the y-axis. You dont need to add formatting for this part the default is fine.
(j) Label the x-axis and the y-axis and add a title to your plot.
(k) Add a legend to your plot indicating the coefficients of friction.
(l) Run this section of your script.
(m) Paste your plot and your MATLAB commands in the spaces indicated below.
Paste MATLAB commands from your script file here: %% Homework 2: Problem 3
G=0.01;tr=2;
V_mph=0:0.1:80;
V=V_mph.*1.60934;
S1=(((0.278*V).^2)/(19.6*(0.7-G)))+(0.278*V)+tr;
S2=(((0.278*V).^2)/(19.6*(0.4-G)))+(0.278*V)+tr;
S3=(((0.278*V).^2)/(19.6*(0.1-G)))+(0.278*V)+tr;
S1_ft=S1.*3.28084;S2_ft=S2.*3.28084;S3_ft=S3.*3.28084;
plot(V_mph,S1_ft,V_mph,S2_ft,V_mph,S3_ft);
xlabel('Vehicle Speed (mph)');ylabel('Stopping Sight Distance (feet)');
title('Stopping Sight Distance vs Vehicle Velocity');
legend('f=0.7','f=0.4','f=0.1');

Paste plot here:


Stopping Sight Distance vs Vehicle Velocity

3000

f=0.7
f=0.4
f=0.1

Stopping Sight Distance (feet)

2500

2000

1500

1000

500

10

20

30
40
50
Vehicle Speed (mph)

60

70

80

What to turn in:


Submit an electronic copy of your work to your individual section of Blackboard look for
Homework #1. Include your completed .docx file (pdf OK too) and your script file.
Note: You can attach more than one document in a single submission. Once you hit submit,
be patient and wait attachments take a while to upload. Hitting submit multiple times will
result in multiple submissions.

Você também pode gostar