Is there a way to get the input argument index of a function?
Show older comments
I am trying to read specific files from big database. Files are codenamed base on parameters Pn in a specific order within a range of tested values Vn: "Name_P1V1_P2V8_P3V4.csv"
To achieve this, I created a function that recieves vectors of specific values Vn to then load those specific datasets.
[OutputDB] = ReadFiles(P1,P2,P3);
I have a list of the specific values Vn that each parameter Pn could have, example for P1:
P1possible = [V1,V2,V3];
Since there are different parameters, values Vn for each Pn are unique. I thought of generating the address strings through a simple nested For
for P = 1:1:nargin
for V = 1: length(InputArgument(P)) %Input parameter vector length
switch P
% Input detection code with error handling
end
end
end
There are multiple ways of solving this issue like looping each parameter individually,I have read about varargin function and think that it could also be a solution, however I was wondering if there was a way to actually reference the input arguments individually.
I'm still learning how to program so this may be a silly question. If I should post this somewhere else, please let me know.
Thanks in advance for any help
2 Comments
prasanth s
on 11 Feb 2023
one can also store all input arguments in a cell array and pass the array to the function.
Rik
on 11 Feb 2023
Perhaps varargin would help, although I must admit that I don't fully understand what you want.
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!