I need to extract the actual name of my input variable for naming a file. Here is my simple script.
function bmp=array2bmp(a) bmp=uint8(a); nam=strcat(varname(a),'.bmp'); imwrite(bmp,nam,'bmp'); end
and varname is a function defined as such
function n=varname(var) n=inputname(1); end
so if I have an array named 'testbmp' and I type
bmp=array2bmp(testbmp);
My output is a .bmp file named 'a.bmp' not 'testbmp.bmp'. This does not make sense to me. Is there a way I can call the actual name of my actual input variable instead of whatever dummy variable I wrote in the function?
Best Answer