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!

 Akzeptierte Antwort

Matt Kindig
Matt Kindig am 23 Jul. 2012
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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Hilfe-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