assigning images to appdata and checking if exists
3 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Adam
on 7 Oct 2015
Edited: Adam
on 7 Oct 2015
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!