# MATLABEXP2.docx - EXPERIMENT-2(A(i AIM To write MATLAB code...

• 13

This preview shows page 1 - 5 out of 13 pages.

EXPERIMENT-2(A)- (i) AIM: To write MATLAB code for finding area of curves. KEYWORD: If f and g are continuous with f (x) ≥ g(x) for x [a,b] , then the area of the region between the curves y = f (x) and y = g(x) from a to b is the integral A = ¿ ¿ a b ¿ f (x) -g(x)]dx Also, if a region’s bounding curves f and g are described by functions of y , where f denotes the right hand curve and g denotes the left hand curve, f (y) - g(y) being non negative, then the area of the region between the curves x = f (y) and x = g(y) from y = c to d is the integral A = ¿ ¿ c d ¿ f (x) -g(x)]dx
The area bounded by the curves y = 2 - x 2 and the line y = -x, from x = -1 to 2: MATLAB Code: clear clc syms x f(x)=2-x^2; g(x)=-x; I=[-1,2]; a=I(1); b=I(2); A=int(f(x)-g(x),a,b); disp('Area bounded by the curves f(x) and g(x) is:' ); disp(A); fplot(f(x),[a,b]);grid on;hold on; fplot(g(x),[a,b]);hold off xlabel('x-axis');ylabel('y-axis'); legend('y=f(x)','y=g(x)');
OUTPUT Area bounded by the curves f(x) and g(x) is: 9/2 GRAPHS
EXPERIMENT-2(A)- (ii) AIM: To write MATLAB code for finding volume of solid of revolution.