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 件のコメント

Abel
Abel 2011 年 10 月 22 日
Don't know how I missed that, thanks!

サインインしてコメントする。

 採用された回答

the cyclist
the cyclist 2011 年 10 月 22 日

0 投票

Notice the one additional period I added:
quad('(5+log(x))./(x.^2+1)',1,4)

その他の回答 (1 件)

Wayne King
Wayne King 2011 年 10 月 22 日

0 投票

You need a ./ in your division.
For example:
x = 1:.01:4;
quad(@(x) (5+log(x))./(x.^2+1),1,4)

製品

タグ

質問済み:

2011 年 10 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by