Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Using figure handles outside of function in which they're defined
Replies: 1   Last Post: Feb 7, 2013 12:37 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 8,195
Registered: 6/7/07
Re: Using figure handles outside of function in which they're defined
Posted: Feb 7, 2013 12:37 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 2/7/2013 10:46 AM, Chaitanya Bhat wrote:
> Hi all, Here's what I'm attempting...
> 1) I define a figure handle 'h=plot(x,y)' in one function.
> 2) I declare 'h' as global
> 3) I recall this 'h' in a different function, trying to use it with
> 'copyobj(h,handles.axes1)' where axes1 is a different axes than where
> 'h' was originally plotted.
>
> I get an error with copyobj, that 'h' is an invalid handle.
>
> As a check, I tried using the copyobj command, similarly, but within the
> first function where 'h' was originally defined. And that works just fine.
>
> Am I to understand that I cannot use figure handles this way, declaring
> them as globals, between multiple functions? Is there a way around this?


The handle itself is only valid for the given object in the given object
hierarchy--its value is of no meaning in any other context.

To use an object which is a copy via copyobj, you create a new instance
handle of the copy in the new object hierarchy. There's an example of
this in

doc copyobj

You can, of course, make handles global and access them from various
contexts, but they always must refer back to the original object;
they're of no value other than that.

They're no different in that regard than, say, a fid handle obtained for
i/o on an external file--that fid isn't of any relevance to anything
except i/o on that particular file while that particular connection
is/remains unbroken.

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.