Access uitable data from uicontrol button question

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by