pi_matlab.m 142 Bytes
function pi = Pi_matlab( n )

h = 1.0/n;
pi = 0.0;

for i=1:n
  x = (i + 0.5)*h;
  pi = pi+ (4.0/(1.0 + x*x));
  end
 pi=pi*h;
 disp(pi)
end