MATLAB: Assigning images to appdata and checking if exists

imagessetappdata

After saving an image IM into appdata using
img=setappdata(0,IM,'pic')
I want to be able to check if this field 'pic' exists later. The reason is that I haver radio buttons that autoscale an image and I only want them to perform the autoscale routine if the image has been saved into memory using appdata.
Later when I retrieve the image by:
img=getappdata(0,'pic')
If the image isn't there,then I don't want the autoscale routine to continue (as it has nothing to autoscale and crashes)
I have tried:
isfield(0,'pic')
but this didn't work.
Is there another way to check whether the IM has already been assigned the 'pic'
Thanks Jason

Best Answer

isappdata(h,name)
should work for this, h being 0 in your case I guess, name being 'pic'.
As an aside, I don't use appdata myself except on rare occasions, but I would have thought you would want to set the appdata of your figure, not the root object.