function with xmin causes error

15 ビュー (過去 30 日間)
Svenja Delle
Svenja Delle 2017 年 3 月 30 日
コメント済み: Svenja Delle 2017 年 3 月 30 日
I am supposed to create xmin as a function but no matter what I try MatLab always displays:
Error using minfun
Too many input arguments.
My code looks like this:
function xmin=minfun(x)
n=length(x);
xmin=x1;
for k=2:n
if (x(k)<xmin)
xmin=x(k);
end
end
end
I really have no idea where I made a mistake...

採用された回答

Walter Roberson
Walter Roberson 2017 年 3 月 30 日
The problem is in how you execute the function. You need to go to the command line and type in the function name and the input argument. For example,
minfun([pi exp(2) sqrt(5)])
  1 件のコメント
Svenja Delle
Svenja Delle 2017 年 3 月 30 日
Oh it's such a stupid mistake. Thank you so much you saved my day. :)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by