Is there a way to pass the inputs in varargin to fprintf within a loop?
For example if you have something like:
function = func_name(var1,varargin)
for i = varargin
fprintf('The first name is %s , another is %s',var1,varargin)
end
If the inputs are name1 name2 and name3, I want the loop to output:
The first name is name1, another is name2
The first name is name1, another is name3
fprintf can't take cell inputs, and changing varargin to varargin{:} (making it a separated list) is not exactly what I want either because it doesn't separate out the varargin inputs into separate loops.
I also can't use inputname() because if the input is an expression rather than a single variable, Matlab returns an empty string '' when calling input name. Is there some way to still use inputname() and add a counter to the loop, or to index the varargin inputs and cycle through them?