Faculty of Manufacturing & Mechatronic Engineering Technology “In the name of Allah, The Most Beneficent, The Most Merciful” BFM 3002: COMPUTER SIMULATION ASSIGNMENT #6: USER-CONTROLLED INPUT AND OUTPUT Prepared By: Ts Dr Nafrizuan Mat Yahya Due Date: Assignment Objectives: • • • • • Apply solution to a problem of Input Function Apply solution to a problem of disp Function Apply solution to a problem of fprintf Apply solution to a problem of combining the input, disp and fprintf Commands Apply solution to a problem of ginput There are five (5) questions. Please answer all questions. Date: ____________________ Group Members Student ID Section /50 // In the name of *ALLAH/ GOD, we declare that this is our original work. BFM3002 Computer Simulation Assignment 6 Page 2 of 4 Question 1 (5 Marks) Figure 1: Volume of a cone The volume of a cone is: π= 1 × ππππ ππ π‘βπ πππ π × βπππβπ‘ 3 Create an M-file that prompts the user to enter the area of the base and the height of the cone as in Figure 1. Calculate the volume of the cone. Question 2 (7 Marks) a) Use two separate input statements to prompt a user to enter his or her first and last names. Use the disp function to display those names on one line. (You’ll need to combine the names and some spaces into an array.) b) Prompt the user to enter an array of numbers. Use the length function to determine how many values were entered and use the disp function to report your results to the command windows. Question 3 (10 Marks) Very small dimensions-those on the atomic scale-are often measured in angstroms. An angstrom is represented by the symbol, Å and corresponds to a length of 10-10 m. Create an inches-to-angstroms conversion table as follows for values of inches from 1 to 10: • Use disp to create a title and column headings. BFM3002 Computer Simulation Assignment6 Page 3 of 4 • Use fprintf to display the numerical information. • Because the length represented in angstroms is so big, represent your result in scientific notation, showing two values after the decimal point. This corresponds to three significant figures (one before and two after the decimal point). Question 4 (15 Marks) This problem requires you to generate temperature conversion tables. Use the following equations, which describe the relationships between temperature in degrees Fahrenheit (TF), degree Celsius (TC), kelvins (TK) and degree Rankine (TR), respectively: ππΉ = ππ − 459.67° π 9 ππΉ = ππΆ + 32° πΉ 5 ππ = 9 π 5 πΎ You will need to rearrange these expressions to solve some of the problems. a) Generate a table of conversion from Fahrenheit to Kelvin for values from 0ºF to 200ºF. Allow the user to enter the increments in degree F between lines. Use disp and fprintf to create a table with a title, column headings, and appropriate spacing. b) Generate a table of conversions from Celsius to Rankine. Allow the user to enter the starting temperature and the increment between lines. Print 25 lines in the table. Use disp and fprintf to create a table with a title, column headings and appropriate spacing. c) Generate a table of conversions from Celsius to Fahrenheit. Allow the user to enter the starting temperature, the increment between lines, and the number of lines for the tables. Use disp and fprintf to create a table with a title, column headings and appropriate spacing. BFM3002 Computer Simulation Assignment6 Page 4 of 4 Question 5 (13 Marks) At time t =0, when a rocket’s engine shuts down, the rocket has reached an altitude of 500 m and is rising at a velocity of 125 m/s. At this point, gravity takes over. The height of the rocket as an function of time is β(π‘) = − 9.8 2 π‘ 2 + 125π‘ + 500 for π‘ > 0. Plot the height of the rocket from 0 to 30 seconds, and: • Use the ginput function to estimate the maximum height the rocket reaches and the time when the rocket hits the ground. Plot the graph to visualize the heights when the time is from 0 to 30 seconds. • Use the disp command to report your results to the command windows. BFM3002 Computer Simulation Assignment6