Error using handle.handle/set

2 Ansichten (letzte 30 Tage)
Hesham Ismail
Hesham Ismail am 5 Jun. 2015
Beantwortet: Guillaume am 5 Jun. 2015
Hello,
I am trying to run this code, but I keep getting error
I am trying to have a patch updating on a background plot.
clear;clc;close all;
h.xt=patch(0,0,'b','erasemode','xor');
h.pth= plot(0,0,'k','markersize',2,'erasemode','background');
wp=[5 1;6 2;7 3]
veh=[0 -4 -4;0 -2 2];
set(h.pth,'xdata',wp(:,1),'ydata',wp(:,2),'Marker','o')
set(h.xt,'xdata',veh(1,:),'ydata',veh(2,:))

Akzeptierte Antwort

Guillaume
Guillaume am 5 Jun. 2015
plot deletes the previous content of the figure, unless you use hold on, hence your patch handle becomes invalid as soon as you create the plot. To fix:
h.xt=patch(0,0,'b','erasemode','xor');
hold on
h.pth= plot(0,0,'k','markersize',2,'erasemode','background');

Weitere Antworten (0)

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by