The area and perimeter a circle of radius r are found with t
The area and perimeter a circle of radius r are found with the following expressions: A = pir^2 and P = 2pir Write a MATLAB Script file called circle Perimeter Area. m that calculates the area and perimeter of a circle by entering the formulae above. Set the radius r to 10 feet. Let z = 3x - x^3/xy + 2y. Set x = [6 3 -2 4] and y = [5 1 11 -7]. Write MATLAB code to obtain z from the above formulae.
Solution
%3
prompt = \'Please enter radius of circle: \';
r = input(prompt)
%calculate area of circle on given radius
Area=pi * r^2;
%calculate perimeter of circle on given radius
perimeter=2*pi*r;
%X = [\'Area of circle = \',num2str(Area),\' \'];
%disp(X);
fprintf(\'Area of circle = %f \ \', Area);
fprintf(\'Perimeter of circle = %f \', perimeter);
%{
output:-
Please enter radius of circle: 5
r = 5
Area of circle = 78.539816
}%
---------------------------------------------
4)
x = [6 3 -2 4];
y=[5 1 11 -7];
t=3*x-x.^3;
p=x.*y+2.*y;
z=t./p;
disp(\'output of z:\');
disp(z);
%{
output of z:
-4.9500 -3.6000 Inf 1.2381
}%
