hw_61.pdf

HW 6 (Lab 8)

Assigned On: Wednesday October 14th 2015, at 12 PM (noon).

Due Date and Time: Wednesday October 21st 2015, at 12 PM (noon).

Submission: To be uploaded (all the solution files must be put inside a folder, the folder should then be compressed or zipped, and that zipped folder is uploaded) onto the blackboard assignment webpage by the student, under the correct lab number folder in the Assignments webpage. Remember to upload it on the HW (not Lab Work) upload page link!

Naming your file and folder: Please save solutions to each problem in a separate file (one m- file for each problem).

The name of the file should be as given below: YourLastName_YourFirstNameInitial_HW_ProblemNumber.CorrectExtension

Example: Mysore_D_HW_Problem1.m

CorrectExtension is .doc for word documents, .pdf for pdf documents and .m for script-file or m- files. They are usually generated by default.

Put all the files (solutions of all the problems assigned in that lab) inside one folder. The folder name should be as given below:

YourLastName_YourFirstNameInitial_HW_LabLabNumber

Example: Mysore_D_HW_Lab6

Then zip that folder and upload the folder onto the Assignments webpage of your blackboard under the appropriate lab number.

Total Points: 20 (regular) + 5 (extra credit)

Please read the instructions and the problem statement for each of the assignment carefully. When in doubt, ask any one of the GTAs or the instructor, only after you have read the problem statement thoroughly.

ME 208, Fall 2015, Mechanical Engineering, University of Kansas Page 1 of 2

1. Problem 1 Write a program to create 3x2 size cell array. Your cells will have the following in them:

1. Your cell in 1st row and 1st column (1,1) should have a string. But this string will be obtained from the user by requesting the user to input a string. Ask the user to enter the full name of a student.

2. Your cell in 1st row and 2nd column (1,2) should have a string. This string will read ‘Name of the user’.

3. Your cell in 2nd row and 1st column (2,1) should have a 1D array. This will also be obtained from the user. To do that, first ask the user to enter the number of elements of a 1D array, between (and including) 1 and 10. If the user inputs an invalid number, then keep asking the user to input a number within this range. Only when the user inputs the number in a correct range (say n), then proceed to create a 1xn matrix or array. Here, you can either ask the user to input an array using the input function (but make sure to specify the way the user has to input an array, i.e. enclosed within square brackets and separated by commas, or semi-colons, or spaces, etc.). Or, you may have the user input an array, say using a loop, into another variable. And then assign that variable to the cell. If you think of any other way, you are welcome to use that as well. But each element in the array has to be between (and including) 1 to 10. If any one of the elements of numerical array is out of this range, assign then assign that variable containing the out or range number equal to 0.

4. Your cell in 2nd row and 2nd column (2,2) should have a string. This string will display the number of courses for which the grades are present. For example, if the user inputs, say n = 5 (in cell (2,1)), then the string in my cell (2,2) will read “The student has taken 5 courses”. Notice that if the input for n would may be different than 5, so it should be a variable. Hint: You may want to use num2str option in your string when you assign it to the cell (2,2).

5. Your cell (3,1) should have the average value of the array contained in cell (2,1). 6. Your cell (3,3) should display a string that says if the student “Passed” or “Failed”,

depending on whether the student has a mean value greater than or equal 60% (6 out of 10), or less than 60% (6 out of 10), respectively.

7. Finally, display all the contents of the data structure in all the cells. You may use celldisp function of MATLAB.

ME 208, Fall 2015, Mechanical Engineering, University of Kansas Page 2 of 2

  • 1. Problem 1