How do I extract a variable name using varargin?

5 views (last 30 days)
Hello,
I am using varargin in a GUI to allow the user to enter in as many inputs as required, and then plot the input data on a figure. I would like to convert the input argumets into a string that I can use for a legend and/or a title on the figure. I cannot figure out how to extract the variable names using varargin. Is there a way to do this?
Thank You, -Eric

Accepted Answer

Walter Roberson
Walter Roberson on 25 Mar 2013
inputname() can still be used when you have varargin.
function blip(a, b, varargin)
for K = 1 : nargin
fprintf('input #%d came from variable "%s"\n', K, inputname(K) );
end

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!