GUI Plot won't update inside 'MousePressedCallback' function

조회 수: 4 (최근 30일)
Carlos
Carlos 2015년 9월 2일
편집: Carlos 2015년 9월 3일
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
Carlos
Carlos 2015년 9월 2일
%-------------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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by