How to extract data from a figure which contains a uitable?

Hi I'd like to extract data from a saved .fig file which contains a uitable. And I want to load the data into a matrix, so that I can use it in another matlab function. How to do it? I tried the following code:
open('(2039,2,0,1).fig');
%(2039,2,0,1).fig is the file to extract data from
x=get(gcf,'Children');
display(x);
And matlab gives me a number not in my figure.
So how to do it? Thanks a lot in advance!

 Respuesta aceptada

The number that is given when you do get(gcf,'Children') is the handle to one of the child objects (presumably the uitable if that's the only object in the figure). You can check this by checking the 'type' property of x.
To get the data,
x = get(gcf,'Children');
if strcmpi( get(x,'type'), 'uitable'), %x is uitable
data =get(x,'Data'); %this is the uitable data
end

2 comentarios

thanks!
Or for a situation where you have multiple objects (including a uitable):
x = findobj(gcf,'Type','uitable');
if ~isempty(x),
data = get(x,'Data');
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by