Access uitable data from uicontrol button question

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Walter Roberson
Walter Roberson il 12 Ago 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.

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by