Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
getappdata doesn't capture all handles
조회 수: 1 (최근 30일)
이전 댓글 표시
hi all,
I'm using a uitable in order to mark specific points on another figure (upper left in the attached image).
when I check a box in the "show" column it does mark an x at the figure as I want it to. but when I am unchecking the boxes, only the last x is deleted from the figure. it seems as the getappdata in callback1 function capture only the last handle.
these are the lines by which I define the uitable:
t=uitable(figure(1),'data',uidata,'columnname',titles,'fontsize',15,'ColumnWidth',{100});
subplot(2,2,[2,4]);
ax = gca
ax.Visible = 'off'
pos = get(subplot(2,2,[2,4]),'position');
set(t,'units','normalized');
set(t,'position',pos);
t.ColumnEditable(1)=1;
figure(3);p1=plot(1:3);
setappdata(f1.Parent,'ellipseHandle',p1);
t.CellEditCallback={@(src,eventdata)callback1(src,eventdata,f1,data)};
close(3)
callback1 function:
function callback1(h,eventdata,F,data)
ind=find([h.Data{:,1}]);
eh=getappdata(F(1).Parent,'ellipseHandle'); %ellipse handle
delete(eh);
for i=ind
eh(i)=plotData(F(1),data,ind);
end
setappdata(F(1).Parent,'ellipseHandle',eh);
end
plotData function:
function [h]=plotData(frame,data,i)
for k=1:length(i)
f=find (data(i(k),:)==0,1);
if f>0
p=1:(f-1);
p(1)=data(i(k),1); p(2)=data(i(k),2);
for j=3:2:f-1
p(j)=data(i(k),j);
p(j+1)=data(i(k),j+1);
end
else
p=1:(length(data(i(k),:)));
p(1)=data(i(k),1); p(2)=data(i(k),2);
for j=3:2:size(data,2)-1
p(j)=data(i(k),j);
p(j+1)=data(i(k),j+1);
end
end
hold on
h=plot(frame,p(3:2:end-1),p(4:2:end),'xb');
end
% hold off
end
댓글 수: 0
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!