integrating function from -inf to +inf
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
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
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)
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Computations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!