Uploaded by Pidge Ω‹Freeman

Assignment6

advertisement
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
Download