How to store data from pushbutton within a nested function?
显示 更早的评论
I feel like this is a super easy fix, but I cannot seem to figure out how to store a variable within a nested function...Here is my function so far
data_labels and step_labels are variable length cell arrays, while input_labels is a variable length array of sequential numbers between 1 & 10.
My issue is I can get my pushbutton to correctly output 'vals' via the display, but when I try storing vals outside of the push_call function, I cannot seem to get it to overwrite the zeros array.
function vals = MyGUI2(data_labels,input_labels,step_labels)
num_inputs = max(input_labels) - min(input_labels) +1;
num_steps = max(size(step_labels));
components_index = step_labels;
h.table = uitable('units', 'pixels', 'position',...
[10, 10, num_inputs*110, num_steps*40],...
'columnname', data_labels,...
'columnformat', {'logical'}, 'ColumnEditable', true,...
'rowname', step_labels,...
'data', true(numel(components_index),num_inputs));
% Creates a pushbutton to save data
vals = zeros(num_steps,num_inputs);
h.push = uicontrol('style','pushbutton','units','pixels',...
'position',[num_inputs*200/4,50,80,40],'string','Done',...
'callback',@push_call);
function vals = push_call(varargin)
vals = get(h.table,'data'); % determines which boxes are checked
disp(vals) % just displaying your values that you have selected
end
% need to strore vals somehow!
end
Thanks in advance :)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
