I'm trying to dynamically add information to a 3D plot:
A = [ -8/3 0 0; 0 -10 10; 0 28 -1 ];
y = [35 -10 -7]';
h = 0.01;
p = plot3(y(1),y(2),y(3),'.','EraseMode','none','MarkerSize',2);
axis([0 50 -25 25 -25 25])
hold on
while 1
A(1,3) = y(2);
A(3,1) = -y(2);
ydot = A*y;
y = y + h*ydot;
set(p,'XData',y(1),'YData',y(2),'ZData',y(3))
drawnow
end
I get the following errors:
Warning: The EraseMode property is no longer supported and will error in a future release.
In strange_attractor (line 4) Warning: The EraseMode property is no longer supported and will error in a future release.
In strange_attractor (line 4) Error using matlab.graphics.chart.primitive.Line/set Invalid or deleted object.
Error in strange_attractor (line 12) set(p,'XData',y(1),'YData',y(2),'ZData',y(3))
I understand that I'm using the outdated syntax for dynamically updating the plot that is no longer supported. How do I make it work?
Note that I don't want to call plot3 inside the loop, because it makes the graphing slow and consumes a lot of memory. I hope to call plot3 once and just add new points to the existing plot inside the loop. Can it be done in the new version?
Matlab version: R2018a

plot3usage outside your loop withplot3(y(1),y(2),y(3),'.','MarkerSize',2);and replaceset(.....): with thisplot3(y(1),y(2),y(3),'.', 'MarkerSize',2);? - Sardar Usama'EraseMode','none'bit from theplot3call and everything should work as before. It is only a warning after all... The error message happened only after you closed the window, didn't it? - Cris Luengo