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

1 Ansicht (letzte 30 Tage)
Adam
Adam am 8 Okt. 2014
Kommentiert: Geoff Hayes am 8 Okt. 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 Kommentar
Geoff Hayes
Geoff Hayes am 8 Okt. 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?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by