integrating function from -inf to +inf

2 visualizaciones (últimos 30 días)
Randy Chen
Randy Chen el 4 de Nov. de 2020
Comentada: Randy Chen el 4 de Nov. de 2020
I'm trying to integrate the following function from -inf to +inf with repsect to x.
fun = @(x) -3.*v.^2 -4.*v.*a./((x.^2+a.^2)*pi) - a.^2./((x.^2+a.^2)^2*pi^2)
fun =
function_handle with value:
@(x)-3.*v.^2-4.*v.*a./((x.^2+a.^2)*pi)-a.^2./((x.^2+a.^2)^2*pi^2)
>> integral(fun,-inf,inf)
Error using symengine
Not a square matrix.
Error in sym/privBinaryOp (line 1030)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in ^ (line 330)
B = privBinaryOp(A, p, 'symobj::mpower');
Error in @(x)-3.*v.^2-4.*v.*a./((x.^2+a.^2)*pi)-a.^2./((x.^2+a.^2)^2*pi^2)
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);
I don't know why i'm getting this error?
by the way v and a are both constants

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 4 de Nov. de 2020
You need use element-wise operator:
fun = @(x) -3.*v.^2 -4.*v.*a./((x.^2+a.^2)*pi) - a.^2./((x.^2+a.^2).^2*pi^2)
%^ put a dot here
  4 comentarios
Steven Lord
Steven Lord el 4 de Nov. de 2020
The integral function is for numeric integration. If you have fixed values for a and v, define variables with those values before creating your fun function. If you want to perform the integration symbolically use the int function on a symbolic expression (not a function handle.)
syms a x
f = a*x^2;
int(f, x, 0, 5)
a = 3;
f = @(x) a*x.^2;
integral(f, 0, 5)
Randy Chen
Randy Chen el 4 de Nov. de 2020
thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by