integral command with function handle

4 次查看(过去 30 天)
Why do I get an error message with the following piece of script? Everything seems OK (I use R2014a by the way)
func=@(x) exp(x^2)/(x^0.5)
func =
@(x)exp(x^2)/(x^0.5)
>> integral(func,0,1)
Error using integral
Too many input arguments.
>>

采纳的回答

VBBV
VBBV 2022-12-11
编辑:VBBV 2022-12-11
May be you have function defined with a name integral. Check the working folder where you might have such function and which takes few input arguments (<=2)
func=@(x) exp(x.^2)./(x.^0.5)
func = function_handle with value:
@(x)exp(x.^2)./(x.^0.5)
integral(func,0,1)
ans = 2.5426
  1 个评论
Ali Kiral
Ali Kiral 2022-12-11
You're right, I realized I had a function m-file (with a name integral) lurking in the working folder. It accepted one input. Now it's history:)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

产品


版本

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by