Clear Filters
Clear Filters

I am using surf command inside time loop. And I want my initial reference surface.

3 views (last 30 days)
I am using surf command inside time loop. And my initial surface is receiving some input. I want to update the surface but without loosing my initial reference surface.

Answers (1)

chicken vector
chicken vector on 26 Apr 2023
Edited: chicken vector on 26 Apr 2023
To plot multiple object you want to use:
hold on;
If you ant to iterate different plot but only retain the first one, the method is to assign the plot to a variable and delete it later in the same iteration or in the next one.
nPoints = 30;
nFrame = 100;
[X,Y] = meshgrid(-3:6/nPoints:3,-3:6/nPoints:3);
Z = peaks(X,Y);
coeff = -(1:1/nFrame:2);
figure;
set(gca,'XColor','None','YColor','None','ZColor','None');
hold on;
surf(X,Y,Z,'FaceAlpha',.3);
view([1,1.5,1.5])
xlim([-5,5])
ylim([-5,5])
zlim([-20,20])
for frame = 1 : nFrame
newSurf = surf(X,Y,Z*coeff(frame),'FaceColor',[.8 .8 .8],'EdgeColor','None','FaceAlpha',0.8);
pause(.05)
delete(newSurf)
end
hold off;
Result:

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!