ENGR1121 – Computing Applications in Mechanical Engineering
Lab Functions
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
Problems 1-5: 3 points each
1. Write a function circle.m that consumes the radius r of a circle, calculates the circumference and area of the
circle: c = 2πr and a = πr 2 , and gives the outputs as c and a.
Write a test program that calls the function circle.m in order to calculate the circumference and area of a
circle with radius 10 mm.
2. Write a function isodd.m that takes as input any integer N and returns a Boolean variable b: true or false (1
or 0) if N is odd or not respectively.
3. Write a function iseven.m that takes as input any integer N and returns a Boolean variable b: true or false
(1 or 0) if N is even or not respectively.
4. Write a function swap.m that takes any two numbers x and y, swaps their values and returns the new,
swapped x and y as outputs.
5. Write a MATLAB function letterGrade.m that takes a grade (scalar value between 0 and 100) and
returns a letter grade (character A, B, C, D or F).
6. (5 points) Write a MATLAB function letterGrade.m that takes a 1D array of grades (values between 0
and 100) and returns a 1D array of letter grades (characters A, B, C, D or F) with the same dimensions as
the array of grades.
• You do not need to pre-allocate the 1D array for this problem.
• Include error handling in your function such that if the user enters values that are not between 0 and
100, it gives an error or displays an appropriate message.
• Test the function from the Command Window for a few such as simple cases: [55, 99 70], etc.
1
Instructor: Dr. Priya Goeser
Lab Functions - Notes
of 1
Report
Tell us what’s wrong with it:
Thanks, got it!
We will moderate it soon!
Struggling with your assignment and deadlines?
Let EduBirdie's experts assist you 24/7! Simply submit a form and tell us what you need help with.
Free up your schedule!
Our EduBirdie Experts Are Here for You 24/7! Just fill out a form and let us know how we can assist you.
Take 5 seconds to unlock
Enter your email below and get instant access to your document