Access uitable data from uicontrol button question

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Ag. de 2016
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.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center 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