Machine Problem 1
Machine Problem 1
Machine Problem 1
OBJECTIVES
• To familiarize the students in Matlab interface.
• To enable the students to use some basic commands.
GRADING SYSTEM
INSTRUCTIONS
A. Opening and closing Matlab.
1. To open Matlab, double click the desktop icon or search and click in the programs.
2. To exit Matlab, either click on Exit Matlab from the File menu or typing quit or exit in the
Command Prompt Window. DO NOT click on the close box on the upper right corner.
3. Matlab has a useful editing feature called smart recall. Just type the first few characters of the
command you want to recall, say 2*, then press the up-arrow key. This would recall the most
recent command starting with 2*.
4. Try the following commands:
>> 0/1 <Enter>
>> 1/0 <Enter>
>> 0/0 <Enter>
Matlab will try to warn you in case you didn’t realize you were dividing by zero but will still give
you the answer Inf. In the last command, another special value is obtained NaN, which means
Not-a-Number.
MACHINE PROBLEM
Answer the following problems using commands in Matlab. Make sure to indicate your commands
in your submission and,
1. Compute the following using the correct order of operations:
a. 2 − 4 ∗ (53−2 + 2 ∗ (5 + 6))
4∗53−2
b. 2 −
2∗(5+6)
4∗53−2
c. 2 − 2
+6
5
2. Compute for the volume of a truncated pyramid with a = 5, b = 3 and h = 10, given the
formula:
1
𝑉 = (𝑎2 + 𝑎𝑏 + 𝑏 2 )ℎ
3
ANSWERS
1.
a. Answer: -106
Command:
>> 2-4*(5^(3-2)+2*(5+6))
b. Answer: 1.0909
Command:
>> 2-(4*5^(3-2))/(2*(5+6))
c. Answer: -1.1250
Command:
>> 2-(4*5^(3-2))/(2/5+6)
2. Answer: 163.3333
Command:
>> a = 5; b = 3; h = 10
>> V=1/3*((a^2)+(a*b)+(b^2))*h