problem with pushbutton callbacks for saving user inputted table data.
显示 更早的评论
Hi all,
I'm looking for help for this probably simple problem of mine.... Basically, in the middle of a more long and various code I need the user to input or modify some data, so I have an editable table, as you can see below. Of this table i want to extract datas once they have been edited by the user. I haven't been able to make a pushbutton callback function in order to simply save the data to a given variable, so I'm trying another way.
In particular in the following code i try to define the struct "export.table" and set it equal to table.Data. Then in the callback of the pushbutton I ask to copy the new values of table.Data to export.table by the function set... Problem is it's not working. Instead it's giving me the following error:
Error using set
Conversion to double from struct is not possible.
So, what I'm asking is basically if anyone can help me in making this workaround of mine to work, or please help me coding the pushbutton callback function properly. In this second case, please tell me how and where I should write this function, because I've tried many things but none worked...
param = {'Baseline' 'a' 1 'Fixed';...
'Volume' 'b' 2 'Free';...
'X0' 'c1' 3 'Fixed'
'Y0' 'c2' 4 'Free';...
'Angle' 't1' 5 'Fixed';...
'S1' 'w1' 6 'Free';...
'S2' 'w2' 6 'Fixed';};
figure(2)
columnname = {'Parameter','Parameter name','Value','Fixed/Free'};
columnformat = {'char','char','numeric',{'Fixed' 'Free'}};
table = uitable('Data', param,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', [false false true true],...
'RowName',[]);
% Set width and height
table.Position(3) = table.Extent(3);
table.Position(4) = table.Extent(4);
table.Position(1) = 100;
table.Position(2) = 100;
export.table = table.Data
p=uicontrol('Style','pushbutton',...
'String','Save the parameters for the fit','Position',[100,75,table.Extent(3),25],'Callback',set(export,'table', get(table,'Data')));
uiwait(gcf);
For completeness I add a trial not working code I wrote for the function, which was saved to a different .m file:
function push_call(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.table,'Data', get(handles.table,'Data'))
end
Thx in advance to those willing to help me!
3 个评论
Jan
2015-12-20
Please post the complete error message. Which line causes the error?
Andrea Calvi
2015-12-20
Walter Roberson
2015-12-21
The red would always include a traceback showing the line the problem occurred on.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 App Building 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!