assigning images to appdata and checking if exists

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

 채택된 답변

Adam
Adam 2015년 10월 7일
편집: Adam 2015년 10월 7일
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.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2015년 10월 7일

편집:

2015년 10월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by