GUI Plot won't update inside 'MousePressedCallback' function

2 views (last 30 days)
This is my current code. MyCellSelectionCallback gets the current selected row(s) of my uitable successfully. However, I would like to update a plot in my gui whenever this callback is executed and store the rows value to the handles structure. I can't figure out how to update my handles structure from inside this generated function. Currently I am able to reset "handles.PLOT" but my axes in my gui will not update and I am unable to retrieve "handles.Rows". Please help.
-----------------Table Update-------------------------
set(handles.uitable,'ColumnWidth',{125 125 125 125 126},'Units','normalized');
jUIScrollPane=findjobj(handles.uitable);
jtable=jUIScrollPane.getViewport.getView;
jtable.setNonContiguousCellSelection(false);
jtable.setColumnSelectionAllowed(false);
jtable.setRowSelectionAllowed(true);
jtable = handle(jtable, 'CallbackProperties');
set(jtable, 'MousePressedCallback',{@MyCellSelectionCallback,gcf});
%-----------------CallBack----------------------
function MyCellSelectionCallback(hObject, eventdata, currFig)
handles=guidata(currFig);
%handles=guidata(hObject);
rows=hObject.getSelectedRows+1;
Speed=table2array(handles.results.Value{rows,1}(:,3))';
idx1=Speed<=10;
idx2=Speed<=20 & Speed>10;
idx3=Speed<=30 & Speed>20;
idx4=Speed>30;
c(idx1)=.1;
c(idx2)=.3;
c(idx3)=.5;
c(idx4)=.7;
cla(handles.PLOT);
set(handles.PLOT,'xtick',[]);
set(handles.PLOT,'ytick',[]);
axes(handles.PLOT)
hold on
NewPlot=color_line(LATITUDE,LONGITUDE,c);
handles.Rows=rows;
% Update handles structure
guidata(currFig);
  1 Comment
Carlos
Carlos on 2 Sep 2015
%-------------Edit----------------
I was able to update the handles by adding this line to the end of the callback.
guidata(currFig,handles);
However, I am still unable to display my new plot to my gui axes. Currently it will only reset but not display.
Any suggestions?

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!