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

1 visualización (últimos 30 días)
Adam
Adam el 8 de Oct. de 2014
Comentada: Geoff Hayes el 8 de Oct. de 2014
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 comentario
Geoff Hayes
Geoff Hayes el 8 de Oct. de 2014
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?

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by