How to plot faster? (3D-Matrix)
2 views (last 30 days)
Show older comments
Hello Friends!
I am currently working on a 3D-Cellular Automaton, which is implemented in a function. I have a 3D-Matrix with different values. I have a Loop which calls the CA-Function, which then changes the Matrix-Values according to some rules and then plots the values with each iteration. Different values are plotted with a different color using scatter3. Because there is a lot of calculation going on, I want the plotting to be as fast/cheap as possible. This how I am doing it at the moment:
Firstly, I find out the indices of the different values:
sz = [x y z]; % x,y,z are the dimensions of my matrix
vec1 = find(ZB(:,:,:,1)==1);
[i1,j1,k1] = ind2sub(sz,vec1);
vec2= find(A3(:,:,:,1)==2);
[i2,j2,k2] = ind2sub(sz,vec2);
vec3 = find(A3(:,:,:,1)==3);
[i3,j3,k3] = ind2sub(sz,vec3);
% etc...
And then I plot them:
view(3);
hold on
h = scatter3(i1,j1,k1,'s',...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[1 0 0]);
b= scatter3(i2,j2,k2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[0 0.5 0]);
d =scatter3(i3,j3,k3,...
'MarkerEdgeColor','k',...
'MarkerFaceColor',[0.4 0.9 0.1880]);
% etc...
set(gca,'XLim',[-5 x+5],'YLim',[-5 y+5],'ZLim',[-5 z+5]);
alpha(b,0.2); % to make the dots transparent
alpha(h,0.5);
rotate3d on
hold off
You think, this is the fastest possible way?
Thanks a lot for your help!!
0 Comments
Answers (0)
See Also
Categories
Find more on Digital Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!