Adding an Extra Input Parameter to the Function
Show older comments
How can I add an extra input parameter to the function below? I want to add switch-case inside the function.
[features,history] = sequentialfs(@fun,X,Y,...
'direction','forward','cv',cvt,'options',dsp_options);
function cl_err = fun(xTrain,yTrain,xTest,yTest)
.....
end
2 Comments
Ameer Hamza
on 25 May 2018
What does switch case have to do with the input arguments? Please clarify your question.
Accepted Answer
More Answers (1)
Guillaume
on 25 May 2018
[features,history] = sequentialfs(@(xTrain,yTrain,xTest,yTest) fun(xTrain,yTrain,xTest,classifier) , ...
X,Y,'direction','forward','cv',cvt,'options',dsp_options);
function cl_err = fun(xTrain,yTrain,xTest,yTest,i)
switch i
...
Basically, create an intermediate anonymous function
@(xTrain,yTrain,xTest,yTest) fun(xTrain,yTrain,xTest,classifier)
which calls fun with the extra argument classifier (which will become i in fun).
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!