ENGR1121 – Computing Applications in Mechanical Engineering
Lab 1D Arrays I: Vector Creation, Vector Calculations and Vector Indexing
Lab due: end of lab
Total points: 20
Labs are to be individual work. You may use MATLAB Marina, MATLAB’s help, and your notes. Lab work will be
graded during lab time and working results must be shown to the lab instructor by the end of the scheduled
lab time. All MATLAB programs and functions must be completed and submitted in accordance with the
Computing Assignment Format and the MATLAB Coding Style. Submit an electronic copy of your lab work to
the appropriate Dropbox Folder in GSU’s Folio by the end of lab. No hard copy needed unless specifically
requested by the instructor.
Grading
Each problem will be graded according to: program design (identifying inputs/givens, process, and outputs;
algorithm) and program style (program comments, variable names, proper formatted input and output
including units) 25%, and program correctness 75%.
Lab Work
1. (5 points) Write a MATLAB program that will create the following 1D arrays:
a. Row vector named v1 containing the values 0.0, 2.0, 5.0, 7.5, -5.0, and 20.
b. Column vector named v2 containing the values 1, -7, 3, 8, and 6.
c. Row vector named v3 containing the values from 0 to 99 with an increment of one.
d. Row vector named v4 containing the values from 0 to 99 with an increment of two.
e. Row vector v34 by concatenating v3 and v4.
f. Row vector named v5 containing 200 values linearly spaced from 0.0 to 5.0.
g. Row vector v6 containing the values from 0 to -250 (reverse order) with an increment of 0.5.
h. Row vector z25 containing 25 zeros.
i. Column vector o40 containing 40 ones.
j. Random row vector r50 with 50 elements.
2. (5 points) Write a MATLAB program that will perform the following operations:
a. Create an array named num with the values 0.0, 2.0, 5.0, 7.5, -5.0, 20, 22, -25.
b. Index the fourth element of num and save the result in the variable num4.
c. Index elements two through five of num and save the result in the variable num2to5.
d. Replace the fourth element of num to be 100.
e. Find the length of num. Set this equal to variable N.
f. Delete the last element in num.
g. Scale all the elements of the 1d array num by five and save the result in the variable numTimes5.
h. Add one to all the elements of the 1d array num and save the result in the variable numPlusOne.
i. Square all the elements in the 1d array num and save the result back in the variable num.
j. Take the square root of all the elements in the 1d array num and save the result back in the num.
1
Instructor: Dr. Priya Goeser ENGR1121 – Computing Applications in Mechanical Engineering
3. (5 points) Velocity of a free-falling parachutist:
a. (2 points) Calculate the velocity of a falling parachutist from time 0 to 25 seconds using the equation:
mg
− ct m
v
=
1 − e ( / ) given m=75 kg; g=9.81 m/s^2 and c=10.5 kg/s.
c
Use an increment of 0.1 seconds in the time vector.
(
)
b. (1 point) Determine (via indexing) and display as output the velocity at 25 seconds.
c. (1 point) Calculate and display as output the average velocity.
d. (1 point) Take a copy of this program to one of the tutors in the ELC to check for correctness and
appropriate formatting. You may do so in-person or via Discord. Make sure that the tutor notes down
your full name.
4. (5 points) Given the following grades for a student in a semester, calculate her GPA:
Courses
Calculus I
English I
Chemistry
Economics
Engineering Graphics
Credits
4
3
4
3
3
Letter grade
A
B
B
C
A
Grade (scaled from the letter grade)
4
3
3
2
4
Create vectors representing credit hours and grades. Use built-in functions such as sum and vector
arithmetic to perform the GPA computation. The letter grade data is only given for your information.
2
Instructor: Dr. Priya Goeser