Control figure visibility outside of a function

2 Ansichten (letzte 30 Tage)
Tanmoy
Tanmoy am 23 Mai 2015
Beantwortet: Walter Roberson am 23 Mai 2015
I have 10 figures, I wanna control their visibility. I did the following to set visibility for each figure. These figures belongs to 5 different functions. Hence, whenever I wanna change the display of figure (for example, I wanna display 1,5,9 now, later I wanna display something else, say 2,5,8), I need to edit/change the function itself.
h1 = figure(1); imshow(edge)
set(h1, 'Visible','Off')
any suggestion how to control the visibility without editing those function, i.e. writing a script or something like that to control which figure number to display?

Antworten (2)

Image Analyst
Image Analyst am 23 Mai 2015
You didn't say how it was to be decided which figures would be displayed or hidden. For example, you could have a GUI with 10 checkboxes on it, where the user can check which figures he wants displayed. The callback of the checkbox would run your code to show or hide the figures.

Walter Roberson
Walter Roberson am 23 Mai 2015
function showfigure(fignum)
set(fignum,'Visible', 'off');
end
function hidefigure(fignum)
set(fignum,'Visible', 'off');
end
Now you can showfigure(5); hidefigure(7);
You can even set things up like this
function showfigures(fignums)
tohide = setdiff(1:10, fignums); %1:10 reflects the 1 through 10 you used
set(fignums, 'visible', 'on');
set(tohide, 'visible', 'off');
end
and then you can showfigures([1,5,9]) to have it turn on 1, 5, 9 and turn off the others.

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