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

1 visualizzazione (ultimi 30 giorni)
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 Commento
Geoff Hayes
Geoff Hayes il 8 Ott 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?

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by