Академический Документы
Профессиональный Документы
Культура Документы
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.
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.
1 areaRectangle.m
clc;
area=length*width;
3 areaSquare.m
clc;
disp('Area of Square');
area=s^2;
areaRightTriangle.m
clc;
area=(h*b)/2;
areaObliqueTriangle.m
clc;
Area=(h*b*sin(angle))/2;
areaCircle.m
clc;
area=pi*r^2;
Area of Circle
areaEllipse.m
clc;
area=pi*major*minor;
4 perimeterSquare.m
clc;
disp('Perimeter of Square');
perimeter=4*s;
Perimeter of Square
perimeterRectangle.m
clc;
disp('Perimeter of Rectangle');
perimeter=2*length + 2*width;
Perimeter of Rectangle
perimeterRightTriangle.m
clc;
perimeter=h+b+sqrt((h^2)+(b^2));
perimeterObliqueTriangle.m
clc;
perimeter=a+b+c;
Enter side a: 4
Enter side b: 5
Enter side c: 9
The perimeter of the oblique triangle is 18.00. >>
circumferenceCircle.m
clc;
disp('Circumference of Circle');
circumference=2*pi*radius;
Circumference of Circle
circumferenceEllipse.m
clc;
disp('Circumference of Ellipse');
circumference=pi*((3*(maj+min))-sqrt((3*(maj)+min)+
(maj+3*(min))));
Circumference of Ellipse
5 volumeCone.m
clc;
disp('Volume of a Cone');
volume=pi*(r^2)*(h/3);
Volume of a Cone
volumeSphere.m
clc;
disp('Volume of a Sphere');
volume=pi*(r^3)*(4/3);
Volume of a Sphere
volumeRectangularParallelepiped.m
clc;
volume=h*l*w;
volumeRightCircularCylinder.m
clc;
volume=pi*(r^2)*h;
volumeCube.m
clc;
disp('Volume of a Cube');
volume=s^3;
Volume of a Cube
6 surfaceareaCone.m
clc;
SA=pi*r*h + pi*(r^2);
surfaceareaSphere.m
clc;
disp('Surface Area of Sphere');
SA=4*pi*r^2;
surfaceareaRectangularParallelepiped.m
clc;
SA=2*(a*b+a*c+b*c);
surfaceareaRightCircularCylinder.m
clc;
SA=2*pi*r*h+2*pi*r^2;
surfaceareaCube.m
clc;
SA=6*a^2;
7 Rectangle.m
disp('Area and Perimeter of the Rectangle');
switch(choose)
case 1;
area=length*width;
case 2;
perimeter=2*length + 2*width;
end
>> Rectangle
Choose 1 or 2: 1
>> Rectangle
8 solidMensuration.m
clc;
switch(choose)
case 1;
disp('Plane Figures');
disp(' 1. Square');
disp(' 2. Rectangle');
disp(' 5. Circle');
switch(plane)
case 1;
disp(' 2. Perimeter');
switch(choose1)
case 1;
case 2;
perimeter=4*a;
end
case 2;
disp(' 2. Perimeter');
switch(choose2)
case 1;
area=l*h;
case 2;
perimeter=2*l+2*h;
case 3;
disp(' 2. Perimeter');
switch(choose3)
case 1;
area=0.5*base*height;
case 2;
c=sqrt(base^2+height^2);
perimeter=base+height+c;
end
case 4;
disp(' 2. Perimeter');
case 1;
Area=(h*b*sin(angle))/2;
case 2;
perimeter=a+b+c;
end
case 5;
disp(' 2. Circumference');
switch(choose5)
case 1;
area=pi*r^2;
perimeter=pi*rad*2;
end
end
case 2;
disp('Solid Figures');
solid=input('\nChoose: ');
switch(solid)
case 1;
choose1s=input('Choose: ');
switch(choose1s)
case 1;
volume=(1/3)*pi*(r^2)*h;
fprintf('The volume of the cone is %0.2f.
',volume );
case 2;
SA=pi*r*h + pi*(r^2);
end
case 2;
switch(choose2s)
case 1;
volume=(4/3)*pi*(r^3);
case 2;
SA=4*pi*(r^2);
end
case 3;
disp(' 1. Volume ')
switch(choose3s)
case 1;
volume=l*w*h;
case 2;
SA=2*l*w + 2*l*h+2*w*h;
end
case 4;
case 1;
volume=pi*(r^2)*h;
case 2;
SA=2*pi*r*h + 2*pi*(r^2);
end
case 5;
switch(choose5s)
case 1;
volume=a^3;
case 2;
SA=6*(a^2);
end
end
end
7. Conclusion:
I therefore conclude that MATLAB is so versatile that it cannot just compute matrices and differential
equations, but also solid mensuration problems. By making use of the script window and making an m file,
you just have to write the formula and make questions where you have to input the necessary conditions to
fulfill the formula. This laboratory exercise made me further understands the functions of MATLAB and its
features. Thanks to this laboratory experiment, I could now make a solid mensuration calculator (solving for
the diameter, circumference, surface area and volume) by just typing codes!
8. Assessment (Rubric for Laboratory Performance):