MATLAB Answers

How to plot faster? (3D-Matrix)

8 ビュー (過去 30 日間)
BananaBandana 2019 年 9 月 18 日
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:
hold on
h = scatter3(i1,j1,k1,'s',...
'MarkerFaceColor',[1 0 0]);
b= scatter3(i2,j2,k2,...
'MarkerFaceColor',[0 0.5 0]);
d =scatter3(i3,j3,k3,...
'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
rotate3d on
hold off
You think, this is the fastest possible way?
Thanks a lot for your help!!

  0 件のコメント

サインイン to comment.

件の回答 (0)

サインイン してこの質問に回答します。

Translated by