Call a figure to show just like a variable

76 Ansichten (letzte 30 Tage)
Kosta
Kosta am 18 Jan. 2017
Bearbeitet: Stephen23 am 18 Jan. 2017
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.

Akzeptierte Antwort

Stephen23
Stephen23 am 18 Jan. 2017
Bearbeitet: Stephen23 am 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.
  3 Kommentare
Kosta
Kosta am 18 Jan. 2017
Never mind, I got it with a slightly different way. Thanks again.
Stephen23
Stephen23 am 18 Jan. 2017
Bearbeitet: Stephen23 am 18 Jan. 2017
To hide a figure:
set(fgh,'Visible','off')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by