cla
nfaces = 5000;
nsides = 6;
nframes = 20;
ang = linspace(0,2*pi,nsides+1)
x = repmat(cos(ang)',[1 nfaces]);
y = repmat(sin(ang)',[1 nfaces]);
z = repmat([1:nfaces],[(nsides+1) 1]);
xoff = repmat(randn(1,nfaces),[nsides+1, 1]);
yoff = repmat(randn(1,nfaces),[nsides+1, 1]);
h = patch(x+xoff,y+yoff,z,z);
h.FaceColor = 'flat';
h.EdgeColor = 'none';
xlim([-8 8])
ylim([-8 8])
tic
for i=1:nframes
xoff = repmat(randn(1,nfaces),[nsides+1, 1]) / 10;
yoff = repmat(randn(1,nfaces),[nsides+1, 1]) / 10;
h.Vertices = h.Vertices + [xoff(:), yoff(:), zeros(nfaces*(nsides+1),1)];
drawnow;
end
disp([num2str(nframes/toc) ' frames per second'])
f = h.Faces;
if size(f,2) > 3
f2 = [];
f2 = [f2; f(:,1), f(:,2), f(:,3)];
f2 = [f2; f(:,1), f(:,3), f(:,4)];
f2 = [f2; f(:,1), f(:,4), f(:,5)];
f2 = [f2; f(:,1), f(:,5), f(:,6)];
end
h.Faces = f2;
xlim([-8 8])
ylim([-8 8])
tic
for i=1:nframes
xoff = repmat(randn(1,nfaces),[nsides+1, 1]) / 10;
yoff = repmat(randn(1,nfaces),[nsides+1, 1]) / 10;
h.Vertices = h.Vertices + [xoff(:), yoff(:), zeros(nfaces*(nsides+1),1)];
drawnow;
end
disp([num2str(nframes/toc) ' frames per second'])
3 Comments
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/163217-patch-performance-with-caxis#comment_250292
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/163217-patch-performance-with-caxis#comment_250292
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/163217-patch-performance-with-caxis#comment_250295
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/163217-patch-performance-with-caxis#comment_250295
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/163217-patch-performance-with-caxis#comment_250318
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/163217-patch-performance-with-caxis#comment_250318
Sign in to comment.