Despite my best programming habits, and in an effort to make my code more modular, I use a couple of places varargin.
Of course, the inputs can vary between each use and I check the names of the variables using inputname() and then load from a .mat file any variables that were not passed in but are needed for the code to run.
But now, I need to use the variables that were passed in that are currently lying in varargin{} — and I need those variable names to be named with what is in inputname{:}…e.g inputname{1}=varargin{1}. I think I could do this with an eval(), but I know that is frowned upon.
I know that [var1, var2, var3]=varargin{:} would work, but the names i need the variables to be called are in inputnams(), and I can't think of how to get this to work.
Is there a good way to get the contents of varargin{} out and into named variables that then lay in the stack?
Thanks!
Best Answer