Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

getappdata doesn't capture all handles

1 Ansicht (letzte 30 Tage)
yonatan s
yonatan s am 15 Feb. 2018
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (0)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by