How do I get the handles of all open figures in MATLAB

后端 未结 4 1086
野性不改
野性不改 2020-11-30 22:38

I have nine open figures in matlab (generated by another function) and I want to print them all to file. Does anyone know how to grab the handles of all open figures in MATL

相关标签:
4条回答
  • 2020-11-30 23:14

    You've get fine answers for the handles mass. But another tip for the original question- print all the figures to file: you can use publish option, without dealing with figrues or handles.

    0 讨论(0)
  • 2020-11-30 23:27

    I think findall should work

    handles=findall(0,'type','figure')

    0 讨论(0)
  • 2020-11-30 23:36

    One of the best things to do is to NOT need to look for the handles. When you create each figure, capture its handle.

    h(1) = figure;
    h(2) = figure;
    ...
    

    As one of the developers here told me:

    They are called handles, because you are supposed to hold on to them

    0 讨论(0)
  • 2020-11-30 23:40

    There are a few ways to do this. One way to do this is to get all the children of the root object (represented in prior versions by the handle 0):

    figHandles = get(groot, 'Children');  % Since version R2014b
    figHandles = get(0, 'Children');      % Earlier versions
    

    Or you could use the function findobj:

    figHandles = findobj('Type', 'figure');
    

    If any of the figures have hidden handles, you can instead use the function findall:

    figHandles = findall(groot, 'Type', 'figure');  % Since version R2014b
    figHandles = findall(0, 'Type', 'figure');      % Earlier versions
    
    0 讨论(0)
提交回复
热议问题