Azzera filtri
Azzera filtri

Visualization volume data like pcolor3

13 visualizzazioni (ultimi 30 giorni)
Xin
Xin il 9 Ago 2018
Modificato: Jaswanth il 1 Ago 2024 alle 4:13
Basically I was looking for a pcolor3 like function that can run in newer version of matlab. The idea of using slice to have multiple section and tune the alpha value does not work in new version. The issue is that only the front slice is shown and the slices behind are blocked. Is there a way to solve this?
I was looking for a function that could possibly produce some figure like below. Thanks a lot!

Risposte (1)

Jaswanth
Jaswanth il 1 Ago 2024 alle 4:12
Modificato: Jaswanth il 1 Ago 2024 alle 4:13
Hi Xin,
In newer versions of MATLAB, you can achieve a similar effect to pcolor3 using the slice function along with FaceAlpha property to tune the transparency across the slices.
Please refer to the following example code demonstrating the above discussed steps:
% Sample volumetric data
[X, Y, Z] = meshgrid(linspace(-2, 2, 50), linspace(-2, 2, 50), linspace(-2, 2, 50));
V = X .* exp(-X.^2 - Y.^2 - Z.^2);
% Create slices
slices = linspace(-2, 2, 5);
h = slice(X, Y, Z, V, slices, [], slices);
% Set properties for transparency
alphaValue = 0.1; % Set a numeric value between 0 (fully transparent) and 1 (fully opaque)
for k = 1:length(h)
set(h(k), 'FaceAlpha', alphaValue, 'EdgeColor', 'none');
end
Kindly refer to the following MathWorks documentation to know more about the slice function mentioned above:
I hope the information provided above is helpful.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by