Access uitable data from uicontrol button question

2 ビュー (過去 30 日間)
Gregory McFadden
Gregory McFadden 2016 年 8 月 12 日
回答済み: Walter Roberson 2016 年 8 月 12 日
I have not worked with uicontrol features much. What I want to do is have a button that runs a function that can utilize the following command
handle(tab1).Data
to get data from a table, so I can work with it. I also will have to pass several other variables into the function.
ff1 = figure('Name','Seg55','units','normalized','outerposition',[0 0 1 1]);
tab1 = uitable(ff1,'Data',StatTable,'ColumnName',cnames,'units','Normalized','Position',[0.05 0.05 0.9 0.9],'Tag','tab1');
btn = uicontrol('Style', 'pushbutton', 'String', 'Export','units','Normalized',...
'Position', [.02 .02 .05 .05 ],...
'Callback', @exportstuff);
I am at a loss at how to get the variables/data I need passed into the @exportstuff function actually into the function. The button calls the function just fine but not even setting global variables has worked to allow the function to retrieve the data and have constants passed to it. I figure I am missing something fundamental, so any help would be greatly appreciated. We are currently still running version 2012b of matlab.

採用された回答

Walter Roberson
Walter Roberson 2016 年 8 月 12 日
btn = uicontrol('Style', 'pushbutton', 'String', 'Export','units','Normalized',...
'Position', [.02 .02 .05 .05 ],...
'Callback', {@exportstuff, tab1});
[...]
function exportstuff(hObject, event, tab1)
tab_data = get(tab1, 'Data');
Note: you cannot use tab1.Data notation because that was not permitted until R2014b.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by