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!

 採用された回答

Matt Kindig
Matt Kindig 2012 年 7 月 23 日

0 投票

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 件のコメント

Yunran Wei
Yunran Wei 2012 年 7 月 24 日
thanks!
Matt Kindig
Matt Kindig 2012 年 7 月 24 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by