Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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.

Respuestas (1)

chicken vector
chicken vector el 26 de Abr. de 2023
Editada: chicken vector el 26 de Abr. de 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:

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by