MATLAB: Two patches in one figure

figureMATLABmatlab function

Hi,
please I'm trying to make two patches in one figure, after plotting the first one it disappears and I get the second one 'disk2' only. I've tried 'hold on' but it doesn't work
basically I've this piece of code for plotting
for ii=1:length(y)
set(disk1, 'xdata', xcirc1(:,ii), 'ydata', ycirc1(:,ii), 'zdata', zcirc1(:,ii));
set(disk2, 'xdata', xcirc2(:,ii), 'ydata', ycirc2(:,ii), 'zdata', zcirc2(:,ii));
drawnow
pause(0.01)
end
Any one could please give me suggestion for solving it.
Thank you.

Best Answer

It should work. Please try it again:
axes('nextplot, 'add'); % Like "hold on"
disk1 = patch('xdata', xcirc1(:,1), 'ydata', ycirc1(:,1), 'zdata', zcirc1(:,1));
disk2 = patch('xdata', xcirc2(:,1), 'ydata', ycirc2(:,1), 'zdata', zcirc2(:,1));
for ii = 1:length(y)
set(disk1, 'xdata', xcirc1(:,ii), 'ydata', ycirc1(:,ii), 'zdata', zcirc1(:,ii));
set(disk2, 'xdata', xcirc2(:,ii), 'ydata', ycirc2(:,ii), 'zdata', zcirc2(:,ii));
drawnow
pause(0.01)
end
If the coordinates are not Inf or NaN and are within the axes limits and the view direction is not parallel to the planes of the circles, the patches must be visible.
Related Question