MATLAB: Using fzero for intesection and “integral” for area calculation

fzerointegral

I'm trying to caluclate the area between the curves from about x=-0.22 and 4 as the intersection happens about in those two places. However having trouble using fzero to find the correct intersects and using "integral" to calculate the area.
clear, clc, clear plot
format short
g=@(x)exp((-x.^2)./2);
h=@(x) x.^2-4.*x;
x=linspace(-1,5,100);
plot(x,g(x));
hold on
plot(x,h(x));
z(1)=fzero(g,-0.22); % dont know how to use
z(2)=fzero(h,4); % dont know how to use

% integral
a=z(1);
b=z(2);
f=@(x) % dont know how to use
q=integral(f,a,b)

Best Answer

clear, clc, clear plot
format short
g=@(x)exp((-x.^2)./2);
h=@(x) x.^2-4.*x;
f=@(x) g(x) - h(x);
x=linspace(-1,5,100);
plot(x,g(x));
hold on
plot(x,h(x));
z(1)= fzero(f,-0.22);
z(2)= fzero(f,4)
% % integral
a=z(1);
b=z(2);
q=integral(f,a,b)