Help: Error using integral (line 85) A and B must be floating point scalars

1 次查看(过去 30 天)
Hey, I am new to Matlab and I am trying to code a graph of the function listed below:
>> x = 10:0.05:20; >> func1 = @(x) 1/sqrt(2*pi)*exp(-x^2/2)
func1 =
@(x)1/sqrt(2*pi)*exp(-x^2/2)
>> func2 = @(x) (13.5-x)*sqrt(30)*(1/5)
func2 =
@(x)(13.5-x)*sqrt(30)*(1/5)
>> y = integral(func1, -9999, func2)
I keep getting this error:
Error using integral (line 85) A and B must be floating point scalars.
Can someone help me fix this error or find a way to circumvent it? Thank you.
  1 个评论
Geoff Hayes
Geoff Hayes 2014-10-8
Adam - if you put a breakpoint at line 85 of integral.m, you will understand the error. A and B are the endpoints for your integral and must be floating point scalars. In your case, A is -9999 which is fine, but B is a function handle, func2.
What is your intent of using func2 as an endpoint? If you were to write out your integral (on paper) what would it look like?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by