How can I plot something like imagesc for the 4D space?

I'm doing a cellular automaton and I have in the space 3D (for each cell) different colors (by numbers assigned from 1 to 5). It's means that for example, in some position I have (i,j,k)= a_color (color is assigned by the numbers 1, 2, 3, 4 or 5 ). Formally, In my code I have the space esp=zeros(N,N,N) (size(esp)= N 3) and I filled it with numbers from 1 to 5 each position. I saved this "filled" as the vector "x", with size(x)= N N N. In 2D is easier with the syntax imagesc(x,[0 5]), this shows the automaton with the different color for ach cell, but in 3D is impossible. Thanks

Answers (1)

See slice: https://www.mathworks.com/help/matlab/ref/slice.html and contourslice: https://www.mathworks.com/help/matlab/ref/contourslice.html. You cannot visualize the 3D volume at the same time, but It will allow visualizing the value of your 3D array at the specified surfaces.

2 Comments

Thanks, but is there a mode to see the vector "x" in the espace "esp" without pass between contour or slide? Just see the different cells in the entire space ?
In that case, there is the issue of transparency. How does the renderer decide which cell to display? One way I can think of is to draw several planes and making them a bit transparent. For example, try
[X,Y,Z] = meshgrid(-2:.2:2);
V = X.*exp(-X.^2-Y.^2-Z.^2);
xslice = -0.5:0.05:0.5;
yslice = [];
zslice = [];
s = slice(X,Y,Z,V,xslice,yslice,zslice);
[s.FaceAlpha] = deal(0.05);

Sign in to comment.

Asked:

on 7 Apr 2020

Commented:

on 7 Apr 2020

Community Treasure Hunt

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

Start Hunting!