problem with pushbutton callbacks for saving user inputted table data.
Mostra commenti meno recenti
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 Commenti
Jan
il 20 Dic 2015
Please post the complete error message. Which line causes the error?
Andrea Calvi
il 20 Dic 2015
Walter Roberson
il 21 Dic 2015
The red would always include a traceback showing the line the problem occurred on.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su App Building in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!