I wanted to ask how I can compute the following integral in MATLAB.
integral( PN(x,m,s), x(-Inf,Inf) , m>0 , s>0.
I have created a function file, pn, which is:
function PN = pn(x,m,s)
PN = exp(-(x-m).^2 ./ (2*s.^2)) ./ sqrt(2*pi*s.^2);
end
and a script begin.m:
%ezplot(@(x)pn(x,0,1),[-3,3]) --> This is OK!
quad(pn(x,m,s),x,-Inf,Inf) --> I can't manipulate this, I tried several ways.
The answer to the integral must be “1”.
quadand other integration routines expect a function handle in its first slot. Also, this function must except vector input and return vector output. To fix your problem, try this instead,This should do what you want.