This question is closed. Reopen it to edit or answer.
How can I get the input arguments of a function and save them into an array ?
1 view (last 30 days)
I'd like to know how to get the input arguments of a function and put them into an array to be able to do a loop. I'm also looking of len(["file1.csv","file2.csv","file3.csv"]) =3 in matlab. Currently, I'm getting this : length(['file1.csv','file2.csv','file3.csv']) =27 and as I want to pass this array to a function to read the 3 files one after an other with a loop. Could you help me please ?
I thank you in advance for all your answers.
Ashutosh Prasad on 12 Nov 2018
You can define your function with a variable length argument list using varargin and then use the index of the cell array to refer to each of your input arguments. Given below is a sample function definition.
if nargin == 3
length(["file1.csv","file2.csv","file3.csv"]) gives an output 3.