MATLAB: Retrieve an object’s name

MATLABmatlab objectsobject recognition

I've used Matlab a long time (10+ years) but for the life of me I can't do something rather stupidly simple: get an object's name (not its class name but the name of a specific instance). For testing purposes, I just need a function to print out the name of a specific instance of an object. Surely there is a straightforward way to do this that I'm overlooking but it doesn't easily show up in any of the help retrievals I've tried. None of my fellow Matlab users here at work could give me any help. (I know I'm going to be red-faced when I learn (relearn?) the method.)

Best Answer

whos
?
x = whos;
idx = cellfun(@(x)strcmp(x,'double'),{x(:).class}); %change 'double' to your class
x(idx).name