Integrate a function that contains a built-in function

Hi,
I'm trying to integrate an anonymous function that contains a built-in function. Here's the code:
if true
fun = @(x,d) (exp(-0.5 * (x - d).^2) * (sign(x)))/(sqrt(2*pi));
q = integral(@(x)fun(x,M(l,i)),-inf, inf
end
Not sure what is causing the problem but it is giving me these error messages:
Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
Error in FILENAME>@(x,d)(exp(-0.5*(x-d).^2)*(sign(x)))/(sqrt(2*pi))
Error in FILENAME>@(x)fun(x,M(l,i))
Error in integralCalc/iterateScalarValued (line 314) fx = FUN(t);
Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 103) [q,errbnd] = vadapt(@minusInfToInfInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
Error in FILENAME (line 77) q = integral(@(x)fun(x,M(l,i)),-inf, inf)
I have no idea why there's an issue with matrix multiplication, as far as I am concerned there are no matrices being multiplied here.
Any help would be greatly appreciated.

Respuestas (1)

fun = @(x,d) (exp(-0.5 * (x - d).^2) .* (sign(x)))/(sqrt(2*pi));

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Preguntada:

el 28 de Jun. de 2018

Comentada:

el 28 de Jun. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by