function B=middle(x) %Evaluates the middle integral, then calls the inside function N=length(x); for j=1:N y1=x(j).^2; y2=4; a=x(j); h=@(y) Inside(y,a); B(j)=quad(h,y1,y2); end function A=Inside(y,c) % Evaluates the inside integral c=c.^2; %Coming from the outside parameter (this is fixed x) N=length(y); for j=1:N b=sqrt(y(j)-c); a=-b; h=@(z)sqrt(c+z.^2); A(j)=quad(h,a,b); end