Info

此问题已关闭。 请重新打开它进行编辑或回答。

I am getting error in this code?

1 次查看(过去 30 天)
rajasekhar reddy ogirala
关闭: MATLAB Answer Bot 2021-8-20
f=@(x)cos(x)/x q(x)=integral(f,0,10)
i am getting error in evaluating that statements in command window
sorry guys i am very new to MATLAB.
Thanks for ur help

回答(1 个)

Mischa Kim
Mischa Kim 2014-2-14
编辑:Mischa Kim 2014-2-14
Rajasekhar, use
f = @(x) cos(x)./x;
q = integral(f,0.1,10)
There is a problem though with f approaching inf as you approach x=0. So you can get close but not all the way.
  2 个评论
Roger Stafford
Roger Stafford 2014-2-14
Actually that integral is divergent at the lower limit of zero. As the lower limit, a, approaches zero, the integral approaches plus infinity in a similar way to -log(a).

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by