I am facing errors in integrating the follow ng function.
xtemp=@(lambda)(((h*c)/(lambda*BoltzmnCst*Ts))^2)/(exp(((h*c)/(lambda*BoltzmnCst*Ts)))-1)
xtempintg= integral(xtemp,0,lambdabg)
Everything excep lambda is a constant and defined.
Following is the error I am getting:
Error using /
Matrix dimensions must agree.
Error in My_Code>@(lambda)(((h*c)/(lambda*BoltzmnCst*Ts))^2)/(exp(((h*c)/(lambda*BoltzmnCst*Ts)))-1)
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 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in My_Code (line 46)
xtempintg= integral(xtemp,0,lambdabg)

 Respuesta aceptada

Star Strider
Star Strider el 12 de Feb. de 2021
First, it will likely be worthwhile to use element-wise operations (‘dot operators’) in appropriate places (here in the division and exponentiation operations):
xtemp=@(lambda)(((h*c)./(lambda*BoltzmnCst*Ts)).^2)./(exp(((h*c)./(lambda*BoltzmnCst*Ts)))-1)
Then add the 'ArrayValued' name-value pair to the integral call:
xtempintg= integral(xtemp,0,lambdabg, 'ArrayValued',1)
When I substituted some random scalars for the other values, that worked correctly.

2 comentarios

Zhaque
Zhaque el 12 de Feb. de 2021
Simply adding the . worked
Star Strider
Star Strider el 12 de Feb. de 2021
Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Preguntada:

el 12 de Feb. de 2021

Comentada:

el 12 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by