How can I plot something like imagesc for the 4D space?
Show older comments
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)
Ameer Hamza
on 7 Apr 2020
0 votes
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
David M.
on 7 Apr 2020
Ameer Hamza
on 7 Apr 2020
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);
Categories
Find more on Surface and Mesh Plots 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!