How to integrate (e^x)/x from limit 1 to 2 using inbuilt commands?

2 ビュー (過去 30 日間)
ROHIT TOLAMBIYA
ROHIT TOLAMBIYA 2018 年 4 月 10 日
回答済み: Birdman 2018 年 4 月 10 日
How to integrate (e^x)/x from limit 1 to 2 using inbuilt commands? i tried doing this by defining a function f using inline and then trying to solve the integration by using quad(f,1,2) An error occurred saying "The integrand function must return an output vector of the same length as the input vector. " please help asap.

採用された回答

Birdman
Birdman 2018 年 4 月 10 日
Basically, Riemann Sum Implementation should help you here:
f=@(x) exp(x)./x;
dt=0.0001;
ii=1:dt:2;
res=0;
for k=1:numel(ii)
res=res+f(ii(k))*dt;
end
res
The res value is the same with
result=integral(f,1,2)
Hope this helps.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by