MATLAB: How to extract a variable name using varargin

guivarargin

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

Best Answer

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