Using Matlab determine the area and perimeter of the shapesS

Using Matlab, determine the area and perimeter of the shapes.

Solution

%%Save as shapareaperimeter.m

%%set length and width

length=30;

width=20;

totalarea=0;

rectarea=length*width;

%%radius of semicircle is half of the width

%%of rectangle

radius=width/2;

semicirclearea=0.5*(3.14)*radius*radius;

%%calculate total area

totalarea=rectarea+semicirclearea;

%%print total area of shape

disp(\'area of shape(rectangle+half circle)(in ft)\',totalarea)

totalperimeter=0;

rectperimeter=2*(length+width);

%%diameter of circle is widht of the rectagle

diameter=width;

%%formula for half circle perimeter

%%(1/2)*PI*d+d

semicircleperimeter=0.5*3.14*diameter+diameter;

totalperimeter=rectperimeter+semicircleperimeter;

disp(\'perimeter of shape(rectangle+half circle)(in ft)\',totalperimeter)

------------------------------------------------------------------------------------------------------------------------

Sample output(Run the file from command Line):

area of shape(rectangle+half circle)
1253.2500
perimeter of shape(rectangle+half circle)
197.1000

 Using Matlab, determine the area and perimeter of the shapes.Solution%%Save as shapareaperimeter.m %%set length and width length=30; width=20; totalarea=0; rec

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site