MATLAB: Optional Function input arguments

functionfunctionsinputMATLABmatlab function

I am writing a function and basically it does a set of command on the inputted matrices, How can i specify that the user can enter any number of matrices as inputs and the code will perform the command on all of them. So if three matrices are inputted then the code runs for the 3 and if 20 are inputted the commands are done for all 20. I hope i explained my problem well enough

Best Answer

You would use varargin,
function theFunction(varargin)
for i=1:numel(varargin)
matrix=varargin{i};
...
end
end