Call a figure to show just like a variable
73 views (last 30 days)
Show older comments
Hello,
I have a project, where in my matlab script I have to create lots of figures. Every time I run the script the figures show either all together or one on top of the other etc.
I would like to know how can I suppress a specific figure from showing, so that every time I run the script I don't end up with many different figures, and also be able to call a figure just like a variable, to show whenever I desire by name.
For example if I set a=10, I can call a as a variable whenever I desire in the command window. Can I do the same with a figure? (i have looked in to the set and gcf, however I did not find exactly what I was looking for there)
Thanks in advance for your help,
Kosta.
0 Comments
Accepted Answer
Stephen23
on 18 Jan 2017
Edited: Stephen23
on 18 Jan 2017
Use the figure handle:
fgh = figure(...)
Using the handle you can set and get and properties of the figure (such as Position, Visible, etc), or delete it altogether. Note that all graphics objects have handles like this, and that if you want to write robust, fast code then you need to specify these handles explicitly:
fhg = figure(...);
axh = axes(fgh,...);
lnh = plot(axh,...);
and then later you can much faster access their properties. Graphics objects and their handles are introduced very well in the documentation:
You will also find hundreds of tutorials online that introduce and explain graphics handles.
Note that every object has properties that you can access using this handle, e.g.:
My advice would be to use just one figure (or just a few), and access all of its component parts explicitly using their handles. Simply delete, add, replace, move, or update their values using their handles.
More Answers (0)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!