I made a guide GUI with an axes plot, an editable table, and several callback functions. I have been beating my head against the wall trying to figure out how to get the plot to update (ala refreshdata) when the user edits the data in the table. I currently have the plot redrawing completely each time table data is edited, but that isn't ideal because I'd like to be able to, for example, zoom in on the plot while the data is being edited and have it stay zoomed in.
The GUI code is 1380 lines and counting so I won't post it here, but below is a simplified version of one of the things I've tried (that doesn't work) and I'd be happy to send the code to anyone interested in helping me out. This is only my 3rd week matlabbing so sorry if I overlooked somewhere that this has already been answered.
function varargout = GUITrial(varargin)...initialization codeendfunction GUITrial_OpeningFcn(hObject, eventdata, handles, varargin)handles.output = hObject;x=1:10;handles.vals=[x' x'.^2 1.1.*x'.^2];set(handles.uitable1,'Data',handles.vals);handles.line1=plot(handles.axes1,handles.vals(:,1),handles.vals(:,2),'YDataSource','handles.vals(:,2)','Color','r');hold on;handles.line2=plot(handles.axes1,handles.vals(:,1),handles.vals(:,3),'YDataSource','handles.vals(:,3)','Color','b');hold off;guidata(hObject, handles);endfunction uitable1_CellEditCallback(hObject, eventdata, handles)handles.vals=get(handles.uitable1,'Data');guidata(hObject,handles);refreshdata(handles.line1);refreshdata(handles.line2);end
Best Answer