Write a Matlab script that can compute the area under the cu
Write a Matlab script that can compute the area under the curve of the function f(x) = e(x^2) from x = 0 to x = 4 using the rectangular rule you learned in Calculus. The script should prompt the user for the number of steps to use in the rectangular rule.
Solution
A = [0,1]; B = [1,2]; C = [1,-1]; % collect coordinates X = [A(1), B(1), C(1)]; % x values Y = [A(2), B(2), C(2)]; % y values % compute area triangle_area = polyarea(X, Y); disp([\'The area of triangle (A,B,C) is \' num2str(triangle_area) \'.\']); % plot triangle figure(1); fill(X,Y, [0,0.4,0]);