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?
采纳的回答
更多回答(1 个)
Wayne King
2011-10-22
You need a ./ in your division.
For example:
x = 1:.01:4;
quad(@(x) (5+log(x))./(x.^2+1),1,4)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!