0% found this document useful (0 votes)
141 views12 pages

Laboratory Exercise No. 3 Simple Solid Mensuration Matlab Program 1. Objective

The laboratory exercise aims to create MATLAB programs to calculate geometric properties of plane and solid figures. Students will create programs to determine the area and perimeter of rectangles, squares, triangles, circles and ellipses. Additional programs will calculate the volume and surface area of cones, spheres, cylinders, cubes and rectangular prisms. The programs utilize inputs from the user and outputs the calculated property.

Uploaded by

dr. rick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views12 pages

Laboratory Exercise No. 3 Simple Solid Mensuration Matlab Program 1. Objective

The laboratory exercise aims to create MATLAB programs to calculate geometric properties of plane and solid figures. Students will create programs to determine the area and perimeter of rectangles, squares, triangles, circles and ellipses. Additional programs will calculate the volume and surface area of cones, spheres, cylinders, cubes and rectangular prisms. The programs utilize inputs from the user and outputs the calculated property.

Uploaded by

dr. rick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Laboratory Exercise No.

3
SIMPLE SOLID MENSURATION MATLAB PROGRAM
1. Objective:
The activity aims to create matlab program that will ask the user to choose between the two types of figures in solid
mensuration and output the area, perimeter/circumference, volume or surface area of a certain figure.

2. Intended Learning Outcomes (ILOs):


The students shall be able to:
2.1 create matlab programs that will determine the area and perimeter of five(5) plane figures
2.2 create matlab programs that will determine the volume and surface area of five(5) solid figures
2.3 use switch…case… break in creating matlab program for a simple solid mensuration problem-solving
situation.

3. Discussion :
Solid Mensuration is a branch of mathematics that deals with the area and perimeter/circumference of plane figures
and volume and surface area of solid figures.

4. Resources:
Matlab

5. Procedure:
1. Using the matlab editor , choose File/New/ Blank m-file , type the following:
clc;
disp('Area of the Rectangle');
length=input('Enter the length of the rectangle: ');
width=input('Enter the width of the rectangle :');
area=length*width;
fprintf('The area of the rectangle is %0.2f. ',area );

2. Save the file as areaRectangle. Run the program and record the results.
3. Create m-file for the area of the square, right triangle, oblique triangle, circle and ellipse.
4. Create m-file for the perimeter of square, rectangle, right triangle, oblique triangle, circle and ellipse. For
circle, use circumference instead of perimeter.
5. Create m-file for the volume of cone, sphere, rectangular parallelepiped, right circular cylinder and cube.
6. Create m-file for the surface area of cone, sphere, rectangular parallelepiped, right circular cylinder and
cube.
7. Using the matlab editor, choose File/New/Blank m-file, type the following:
clc;
disp('Area and Perimeter of the Rectangle');
choose=input('\n 1. Area of the Rectangle \n 2. Perimeter of the Rectangle \n Choose 1 or 2: ');
switch(choose)
case 1;
length=input('Enter the length of the rectangle: ');
width=input('Enter the width of the rectangle :');
area=length*width;
fprintf('The area of the rectangle is %0.2f. ',area );
break;
case 2;
length=input('Enter the length of the rectangle: ');
width=input('Enter the width of the rectangle :');
perimeter= 2*length + 2*width;
fprintf('The perimeter of the rectangle is %0.2f. ',perimeter );
break;
end
8. Create a matlab program that will ask the user to choose between plane figures and solid figures.
If the user will choose plane figures, he will then be ask to choose among the five (5) plane figures as mentioned in
Procedure No. 4. After choosing any of the five (5) plane figures, he will then be ask to choose between area and
perimeter. If the user will choose solid figures, he will then be ask to choose among the five (5) solid figures as
mentioned in Procedure No. 5. After choosing any of the five (5) solid figures, he will then be ask to choose between
volume and surface area. Necessary inputs are needed and the output will be any of the area or perimeter of any of
the five (5) plane figures and any of the volume and surface area of any of the five (5) solid figures.
Course: CHE 205 - Computer Applications for ChE Laboratory Exercise No.: 3
Group No.: Section: CH22FA1
Group Members: Castro, Luis Carlo M. Date Performed: DECEMBER 9, 2019
Date Submitted: JANUARY 6, 2020
Instructor: Engr. Crispulo G. Maranan

6. Data and Results:

Procedure No. Matlab Result


1 clc;
disp('Area of the Rectangle');
length=input('Enter the length of the reactangle: ');
width=input('Enter the width of the rectangle: ');
area=length*width;
fprintf('The area of the rectangle is %0.2f.',area);
2 Area of the Rectangle
Enter the length of the reactangle:32
Enter the width of the rectangle:12
The area of the rectangle is 384.00.>>

3.1 clc;
disp('Area of the Square!');
length=input('Enter the length of the side: ');
area=length^2;
fprintf('The area of the square is %0.2f.',area);
Area of the Square
Enter the length of the side:7
The area of the square is 49.00.>>

3.2 clc;
disp('Area of the Right Triangle');
base=input('Enter the base of the right triangle:');
height=input('Enter the height of the right triangle:');
area=(base*height)/2;
fprintf('The area of the right triangle is %0.2f.',area);
Area of the Right Triangle
Enter the base of the right triangle:32
Enter the height of the right triangle:12
The area of the right triangle is 192.00.>>

3.3 clc;
disp('Area of the Oblique Triangle');
a=input('Enter the length of side a of the oblique triangle: ');
b=input('Enter the length of side b of the oblique triangle: ');
c=input('Enter the length of side c of the oblique triangle: ');
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
fprintf('The area of the oblique triangle is %0.2f.',area);
Area of the Oblique Triangle
Enter the length of side a of the oblique triangle: 12
Enter the length of side b of the oblique triangle: 12
Enter the length of side c of the oblique triangle: 12
The area of the oblique triangle is 62.35.>>

3.4 clc;
disp('Area of the Circle');
radius=input('Enter the radius of the circle:');
area=pi*(radius^2);
fprintf('The area of the circle is %0.2f.',area);
Area of the Circle
Enter the radius of the circle:12
The area of the circle is 452.39.>>

3.5 clc;
disp('Area of the Ellipse');
a=input('Enter the radius of the x-axis of the circle:');
b=input('Enter the radius of the y-axis of the circle:');
area=pi*a*b;
fprintf('The area of the ellipse is %0.2f.',area);
Area of the Ellipse
Enter the radius of the x-axis of the circle:7
Enter the radius of the y-axis of the circle:8
The area of the ellipse is 175.93.>>

4.1 clc;
disp('Perimeter of the Square');
length=input('Enter the length of the side of the square:');
area=length*4;
fprintf('The perimeter of the square is %0.2f.',area);
Perimeter of the Square
Enter the length of the side of the square:2
The perimeter of the square is 8.00.>>

4.2 clc;
disp('Perimeter of the Rectangle');
length=input('Enter the length of the reactangle:');
width=input('Enter the width of the rectangle:');
perimeter=2*(length+width);
fprintf('The area of the rectangle is %0.2f.',perimeter);
Perimeter of the Rectangle
Enter the length of the reactangle:3
Enter the width of the rectangle:4
The area of the rectangle is 14.00.>>

4.3 clc;
disp('Perimeter of the Right Triangle');
short=input('Enter the length of the short side of the right triangle:');
medium=input('Enter the length of the medium side of the right triangle:');
perimeter=medium+short+sqrt((short^2)+(medium^2));
fprintf('The perimeter of the right triangle is %0.2f.',perimeter);
Perimeter of the Right Triangle
Enter the length of the short side of the right triangle:7
Enter the length of the medium side of the right triangle:2
The perimeter of the right triangle is 16.28.>>

4.4 clc;
disp('Perimeter of the Oblique Triangle');
a=input('Enter the length of side a of the oblique triangle:');
b=input('Enter the length of side b of the oblique triangle: ');
c=input('Enter the length of side c of the oblique triangle: ');
perimeter=(a+b+c);
fprintf('The perimeter of the oblique triangle is %0.2f.',perimeter);
Perimeter of the Oblique Triangle
Enter the length of side a of the oblique triangle: 1
Enter the length of side b of the oblique triangle: 2
Enter the length of side c of the oblique triangle: 3
The perimeter of the oblique triangle is 6.00.>>

4.5 clc;
disp('Perimeter of the Circle');
radius=input('Enter the radius of the circle:');
circumference=2*pi*radius;
fprintf('The perimeter of the circle is %0.2f.',circumference);
Perimeter of the Circle
Enter the radius of the circle:2
The perimeter of the circle is 12.57.>>

4.6 clc;
disp('Perimeter of the Ellipse');
a=input('Enter the radius of the x-axis of the circle:');
b=input('Enter the radius of the y-axis of the circle:');
circumference=2*pi*sqrt(((a^2)+(b^2))/2);
fprintf('The approximate perimeter of the ellipse is %0.2f.',circumference);
Perimeter of the Ellipse
Enter the radius of the x-axis of the circle:2
Enter the radius of the y-axis of the circle:5
The approximate perimeter of the ellipse is 23.93.>>

5.1 clc;
disp('Volume of the Cone');
radius=input('Enter the radius of the cone:');
height=input('Enter the height of the cone:');
volume=pi*(radius^2)*(height/3);
fprintf('The volume of the cone is %0.2f.',volume);
Volume of the Cone
Enter the radius of the cone:4
Enter the height of the cone:4
The volume of the cone is 67.02.>>

5.2 clc;
disp('Volume of the Sphere');
radius=input('Enter the radius of the sphere:');
volume=(4/3)*pi*(radius^3);
fprintf('The volume of the cone is %0.2f.',volume);
Volume of the Sphere
Enter the radius of the sphere:72
The volume of the cone is 1563457.57.>>

5.3 clc;
disp('Volume of the Rectangular Parallelepiped');
width=input('Enter the width of the rectangular parallelepiped:');
height=input('Enter the height of the rectangular parallelepiped: ');
length=input('Enter the length of the rectangular parallelepiped: ');
volume=width*height*length;
fprintf('The volume of the rectangular parallelepiped is %0.2f.',volume);
Volume of the Rectangular Parallelepiped
Enter the width of the rectangular parallelepiped:52
Enter the height of the rectangular parallelepiped: 92
Enter the length of the rectangular parallelepiped: 26
The volume of the rectangular parallelepiped is 124384.00.>>

5.4 clc;
disp('Volume of the Right Circular Cylinder');
radius=input('Enter the radius of the right circular cylinder:');
height=input('Enter the height of the right circular cylinder: ');
volume=pi*(radius^2)*height;
fprintf('The volume of the right circular cylinder is %0.2f.',volume);
Volume of the Right Circular Cylinder
Enter the radius of the right circular cylinder:29
Enter the height of the right circular cylinder: 69
The volume of the right circular cylinder is 182303.48.>>

5.5 clc;
disp('Volume of the Cube');
radius=input('Enter the edge of the cube:');
volume=radius^3;
fprintf('The volume of the cube is %0.2f.',volume);
Volume of the Cube
Enter the edge of the cube:8
The volume of the cube is 512.00.>>

6.1 clc;
disp('Surface area of the Cone');
radius=input('Enter the radius of the cone:');
height=input('Enter the height of the cone: ');
surfacearea=pi*radius*(radius+sqrt(height^2+radius^2));
fprintf('The surface area of the cone is %0.2f.',surfacearea);
Surface area of the Cone
Enter the radius of the cone:88
Enter the height of the cone: 82
The surface area of the cone is 57581.95.>>

6.2 clc;
disp('Surface area of the Sphere');
radius=input('Enter the radius of the sphere:');
surfacearea=4*pi*radius^2;
fprintf('The surface area of the sphere is %0.2f.',surfacearea);
Surface area of the Sphere
Enter the radius of the sphere:32
The surface area of the sphere is 12867.96.>>

6.3 clc;
disp('Surface area of the Rectangular Parallelepiped');
w=input('Enter the width of the rectangular parallelepiped:');
l=input('Enter the length of the rectangular parallelepiped:');
h=input('Enter the height of the rectangular parallelepiped:');
surfacearea=2*(w*l+h*l+h*w);
fprintf('The surface area of the rectangular parallelepiped is %0.2f.',surfacearea);
Surface area of the Rectangular Parallelepiped
Enter the width of the rectangular parallelepiped:23
Enter the length of the rectangular parallelepiped:21
Enter the height of the rectangular parallelepiped:22
The surface area of the rectangular parallelepiped is 2902.00.>>

6.4 clc;
disp('Surface area of the Right Circular Cylinder');
r=input('Enter the radius of the right circular cylinder:');
h=input('Enter the height of the right circular cylinder:');
surfacearea=2*pi*r*h+2*pi*r^2;
fprintf('The surface area of the right circular cylinder is %0.2f.',surfacearea);
Surface area of the Right Circular Cylinder
Enter the radius of the right circular cylinder:44
Enter the height of the right circular cylinder:11
The surface area of the right circular cylinder is 15205.31.>>

6.5 clc;
disp('Surface area of a Cube');
e=input('Enter the edge of the cube:');
surfacearea=6*a^2;
fprintf('The surface area of cube is %0.2f.',surfacearea);
Surface area of a Cube
Enter the edge of the cube:24
The surface area of cube is 3456.00.>>

7 clc;
disp('Area and Perimeter of the Rectangle:');
choose=input('\n 1.Area of the Rectangle \n 2. Perimeter of the Rectangle \n Choose 1 or 2:
');
switch(choose)
case 1;
length=input('Enter the length of the rectangle: ');
width=input('Enter the width of the rectangle: ');
area=length*width;
fprintf('The area of the rectangle is %0.2f. ',area);
case 2;
length=input('Enter the length of the rectangle: ');
width=input('Enter the width of the rectangle: ');
perimeter=2*length + 2*width;
fprintf('The perimeter of the rectangle is %0.2f. ',perimeter);
end;

Area and Perimeter of the Rectangle:

1.Area of the Rectangle


2. Perimeter of the Rectangle
Choose 1 or 2: 2
Enter the length of the rectangle: 12
Enter the width of the rectangle: 32
The perimeter of the rectangle is 88.00. >>

8 clc;
disp('Area, Perimeter, Volume and Surface Area:');
choose=input('\n 1. Plane Figures \n 2. Solid Figures \n Choose 1 or 2: ');
switch(choose)
case 1;
pick=input('\n 1. Square \n 2. Rectangle \n 3. Right Triangle \n 4. Oblique Triangle \n 5.
Circle \n 6. Ellipse \n Choose 1, 2, 3, 4, 5, or 6: ');
switch(pick)
case 1;
identify=input('\n 1. Area \n 2. Perimeter \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_areaSquare
case 2;
Castro,L_perimeterSquare
end;
case 2;
identify=input('\n 1. Area \n 2. Perimeter \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_areaRectangle
case 2;
Castro,L_periimeterRectangle
end;
case 3;
identify=input('\n 1. Area \n 2. Perimeter \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_areaRightTriangle
case 2;
Castro,L_perimeterRightTriangle
end;
case 4;
identify=input('\n 1. Area \n 2. Perimeter \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_areaObliqueTriangle
case 2;
Castro,L_perimeterObliqueTriangle
end;
case 5;
identify=input('\n 1. Area \n 2. Perimeter \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_areaCircle
case 2;
Castro,L_perimeterCircle
end;
case 6;
identify=input('\n 1. Area \n 2. Perimeter \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_areaEllipse
case 2;
Castro,L_perimeterEllipse
end;
end;
case 2;
pick=input(' \n 1. Cone \n 2. Sphere \n 3. Rectangular Parellelepiped \n 4. Right Circular
Cylinder \n 5. Cube \n Choose 1, 2, 3, 4, or 5: ');
switch(pick)
case 1;
identify=input('\n 1. Volume \n 2. Surface Area \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_volumeCone
case 2;
Castro,L_surfaceareaCone
end;
case 2;
identify=input('\n 1. Volume \n 2. Surface Area \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_volumeSphere
case 2;
Castro,L_surfaceareaSphere
end;
case 3;
identify=input('\n 1. Volume \n 2. Surface Area \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_volumeRectangularParallelepiped
case 2;
Castro,L_surfaceareaRectangularParallelepiped
end;
case 4;
identify=input('\n 1. Volume \n 2. Surface Area \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_volumeRightCircularCylinder
case 2;
Castro,L_surfaceareaRightCircularCylinder
end;
case 5;
identify=input('\n 1. Volume \n 2. Surface Area \n Choose 1 or 2: ');
switch(identify)
case 1;
Castro,L_volumeCube
case 2;
Castro,L_surfaceareaCube
end;
end;
end;

Area, Perimeter, Volume and Surface Area:


1. Plane Figures
2. Solid Figures
Choose 1 or 2: 1
1. Square
2. Rectangle
3. Right Triangle
4. Oblique Triangle
5. Circle
6. Ellipse
Choose 1, 2, 3, 4, 5, or 6: 1
1. Area
2. Perimeter
Choose 1 or 2: 1
Area of the Square
Enter the length of the side:7
The area of the square is 49.00.>>

Area, Perimeter, Volume and Surface Area:


1. Plane Figures
2. Solid Figures
Choose 1 or 2: 1
1. Square
2. Rectangle
3. Right Triangle
4. Oblique Triangle
5. Circle
6. Ellipse
Choose 1, 2, 3, 4, 5, or 6: 2
1. Area
2. Perimeter
Choose 1 or 2: 1
Area of the Circle
Enter the radius of the circle:7
The area of the circle is 153.94.>>

Area, Perimeter, Volume and Surface Area:


1. Plane Figures
2. Solid Figures
Choose 1 or 2: 2
1. Cone
2. Sphere
3. Rectangular Parellelepiped
4. Right Circular Cylinder
5. Cube
Choose 1, 2, 3, 4, or 5: 5
Volume of the Cone
Enter the radius of the cone:3
Enter the height of the cone:5
The volume of the cone is 47.12.>>

7. Conclusion:
I therefore conclude that, MATLAB is very useful in terms of computing areas, perimeters and any plane figures in
field of Mathethics, knowing different formulas of plane figures, just input some codes and then there’s an easy way
to solve the areas and perimeters by just inputting the values of measurements.
TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES
RUBRIC FOR MODERN TOOL USAGE
(Engineering Programs)
Student Outcome (e): Use the techniques, skills, and modern engineering tools necessary for
engineering practice in complex engineering activities.
Program: Chemical Engineering Course: CHE 205 Section: _CH22FA1_ 2ndSem SY 2019 - 2020_
Performance Unsatisfactory Developing Satisfactory Very Score
Indicators 1 2 3 Satisfactory
4
1. Apply Fails to identify Identifies Identifies Recognizes the
appropriate any modern modern modern benefits and
techniques, skills, techniques to techniques techniques and constraints of
and modern tools to perform but fails to is able to apply modern
perform a discipline- discipline- apply these these in engineering
specific engineering specific in performing tools and
task. engineering performing discipline- shows intention
task. discipline- specific to apply them
specific engineering for engineering
engineering task. practice.
task.
2. Demonstrat Fails to apply Attempts to Shows ability Shows ability to
e skills in applying any modern apply to apply apply the most
different techniques tools to solve modern tools fundamental appropriate
and modern tools to engineering but has procedures in and effective
solve engineering problems. difficulties to using modern modern tools to
problems. solve tools when solve
engineering solving engineering
problems. engineering problems.
problems.
3. Recognize Does not Recognizes Recognizes Recognizes the
the benefits and recognize the some the benefits need for
constraints of benefits and benefits and and constraints benefits and
modern engineering constraints of constraints of modern constraints of
tools. modern of modern engineering modern
engineering engineering tools and engineering
tools. tools. shows tools and
intention to makes good
apply them for use of them for
engineering engineering
practice. practice.
Total Score
Mean Score = (Total Score / 3)
Percentage Rating = (Total Score / 12) x 100%
Evaluated by: Engr. Crispulo G. Maranan March 9, 2020
Printed Name and Signature of Faculty Member Date

You might also like