Not enough input arguments: fminbnd

Function file:
function fun = SinExample(x,x1,x2)
x1 = 0;
x2 = 2.*3.14178;
fun = sin(x);
Solution File:
x1 = 0;
x2 = 2.*3.14178;
fun = fminbnd(@SinExample,x1,x2);
I am a beginner and this is a simple example file solving for sin(x). It just says, "Too many input arguments," in line 5 i.e. "fun = fminbnd(@SinExample,x1,x2)." Tried to execute with only the function file:
function fun = SinExample(x,x1,x2)
x1 = 0;
x2 = 2.*3.14178;
fun = sin(x);
fun = fminbnd(@SinExample,x1,x2);
Error-"Not enough input arguments," in line 4 i.e. "fun = sin(x)".
Please yelp.

回答 (1 件)

KSSV
KSSV 2017 年 8 月 28 日

0 投票

fun = @sin;
x1 = 0;
x2 = 2.*3.14178 ;
x = fminbnd(fun,x1,x2)

5 件のコメント

Devdatt Thengdi
Devdatt Thengdi 2017 年 8 月 28 日
Tried that! Too many arguments.
Stephen23
Stephen23 2017 年 8 月 28 日
Show us the complete output of this command:
which sin -all
Jan
Jan 2017 年 8 月 28 日
And please post a copy of the complete error message.
Devdatt Thengdi
Devdatt Thengdi 2017 年 9 月 4 日
The Problem's been resolved. But, Could any of you provide me with a editor code for fminbnd sin. And What do we do if we are getting arguement errors as specified as above?
Stephen23
Stephen23 2017 年 9 月 4 日
"Could any of you provide me with a editor code for fminbnd sin"
KSSV already did.
"And What do we do if we are getting arguement errors as specified as above?"
Restart MATLAB and do not name variables or functions with the names of any inbuilt MATLAB functions.

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

カテゴリ

ヘルプ センター および File ExchangeNonlinear Optimization についてさらに検索

タグ

質問済み:

2017 年 8 月 28 日

コメント済み:

2017 年 9 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by