if you use delete(ObjectHandle)
, the object is destroyed and no recovery is possible. You just have to re-create it the same way you created it in the first place.
Note that this apply for a text
object but also for any type of Matlab object.
If you do not want to delete it, but simply hide it temporarily until you reuse it, then use the visible
property of the text
object.
For example:
set(textHandle,'Visible','off')
will simply make the text object invisible. When you want to make it reappear, switch the property back to 'visible' :
set(textHandle,'Visible','on')
Obviously, this method is only useful if you are sure to reuse your object later on.
Besides the (very small) performance gain (not significant for a single text object, but can be useful if many text objects are to be hidden), the main advantage of doing it this way is that you can still call and modify you text object even when it is hidden. For example:
set(textHandle,'String','New updated text')
will execute fine and will display the 'New updated text'
when the visibility of the text object is restored.
Had you try to set this property after you deleted the object, Matlab would have just be angry at you and send you back the classic error ??? Error using ==> set / Invalid handle object.