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.

回答(1 个)

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by