Organization with structure
You can enter a struct that has these parameters as fields.
For example, a structure with fields
setts.TrainNeg .TrainPos .nf .nT .factors .removeEachStage .applyEstEachStage .removeFeatures
Thus, when you set fields, it becomes clear what a field is, in contrast to a function call, where you need to remember the order of parameters.
Then your function call becomes
[Model threshold] = detect(setts);
and your function definition will be something like
function [model, threshold] = detect(setts)
Then just replace the entries, for example. param with setts.param .
Mixed approach
You can also mix this approach with your current if you want, for example.
[Model threshold] = detect(in1, in2, setts);
if you want to explicitly specify in1 and in2 , and add the rest to setts .
OOP approach
Another option is to include discovery in the class. The advantage of this is that the detect object will have member variables with fixed names, unlike structures, where if you create a typo when setting up the field, you simply create a new field with the wrong name.
for instance
classdef detect() properties TrainNeg = []; TrainPos = []; nf = []; nT = []; factors = []; removeEachStage = []; applyEstEachStage = []; removeFeatures =[]; end methods function run(self) % Put the old detect code in here, use eg self.TrainNeg to access member variables (aka properties) end end