Filter löschen
Filter löschen

Access uitable data from uicontrol button question

2 Ansichten (letzte 30 Tage)
Gregory McFadden
Gregory McFadden am 12 Aug. 2016
Beantwortet: Walter Roberson am 12 Aug. 2016
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Aug. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by