Not enough input arguments.

1 次查看(过去 30 天)
danielle sisserman
danielle sisserman 2020-10-24
评论: Stephen23 2020-11-5
Hi, I am very new to matlab and need some basic help.
function classifier = learnknn(k, d, m, Xtrain, Ytrain)
classifier = {k, d, m, Xtrain, Ytrain};
end
I get the error " Not enough input arguments. "
But, I cannot change the first line of this code. Only the body of the function can be modified.
Thank you.
  7 个评论
danielle sisserman
danielle sisserman 2020-11-5
Thank you Walter.
so if I understand,
function classifier = learnknn(k, d, m, Xtrain, Ytrain)
is actually all I need? no
end
keyword?
and what if I wanted the classifier function to return a diferent datastructure than a cell?
for example, if I wanted to return a list object containing the input objects.
Thankyou.
Stephen23
Stephen23 2020-11-5
"so if I understand, function classifier = learnknn(k, d, m, Xtrain, Ytrain) is actually all I need?"
No, the syntax that Walter Roberson showed replaces your entire function. It uses the special varargin variable:
"and what if I wanted the classifier function to return a diferent datastructure than a cell? for example, if I wanted to return a list object containing the input objects."
MATLAB does not have a "list" type:

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by