How can I plot something like imagesc for the 4D space?
Afficher commentaires plus anciens
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
Réponses (1)
Ameer Hamza
le 7 Avr 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 commentaires
David M.
le 7 Avr 2020
Ameer Hamza
le 7 Avr 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);
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!