Question about using quad function

Hello, I've been trying to integrate a function (5+log(x))/(x.^2+1) using the quad function, so I input
quad('(5+log(x))/(x.^2+1)',1,4)
However, I keep getting the error
Error using quad (line 79) The integrand function must return an output vector of the same length as the input vector.
Can someone help with with this?

 Respuesta aceptada

the cyclist
the cyclist el 22 de Oct. de 2011
Notice the one additional period I added:
quad('(5+log(x))./(x.^2+1)',1,4)

Más respuestas (1)

Wayne King
Wayne King el 22 de Oct. de 2011
You need a ./ in your division.
For example:
x = 1:.01:4;
quad(@(x) (5+log(x))./(x.^2+1),1,4)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 22 de Oct. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by