GUI Plot won't update inside 'MousePressedCallback' function
显示 更早的评论
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);
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!