function with xmin causes error
15 次查看(过去 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...
0 个评论
采纳的回答
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)])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!