How do I extract a variable name using varargin?

4 Ansichten (letzte 30 Tage)
Eric
Eric am 25 Mär. 2013
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Mär. 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

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by