Receiving error messages when trying to numerically integrate this function

1 次查看(过去 30 天)
Hi I am trying to integrate the following funtion numerically and I keep getting the following error messages.
Error using /
Matrix dimensions must agree.
Error in EAS426>@(x)1/(exp(c*h/(x*k*T))-1)*(2*pi*h*c^2/(x^5))
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 91)
[q,errbnd] = vadapt(@minusInfToBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in EAS426 (line 9)
a = integral(s, x1, x2);
h=6.626*10^-34
c=2.99792458*10^8
T=6000
k=1.381*10^-23
s =@(x) 1/(exp(c*h/(x*k*T))-1)*(2*pi*h*c^2/(x^5));
x1 = -Inf;
x2 = 0.4e-6;
a = integral(s, x1, x2);

回答(2 个)

madhan ravi
madhan ravi 2019-2-21
Use dot in front of arithmetic operators in the line s.

KSSV
KSSV 2019-2-21
编辑:KSSV 2019-2-21
h=6.626*10^-34 ;
c=2.99792458*10^8 ;
T=6000 ;
k=1.381*10^-23 ;
s =@(x) 1./(exp(c*h./(x*k*T))-1).*(2*pi*h*c.^2./(x.^5));
x1 = -Inf;
x2 = 0.4e-6;
a = integral(s, x1, x2);
Read about matrix element by element operations: https://in.mathworks.com/help/fixedpoint/ref/times.html

类别

Help CenterFile Exchange 中查找有关 Performance and Memory 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by