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

4 次查看(过去 30 天)
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.

回答(1 个)

chicken vector
chicken vector 2023-4-26
编辑:chicken vector 2023-4-26
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:

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by