How plot 4D data?

122 visualizzazioni (ultimi 30 giorni)
Ali Almakhmari
Ali Almakhmari il 14 Ott 2021
Commentato: Kevin Holly il 14 Ott 2021
Lets say that I have the following data and I would like to plot the function f that is dependent on x, y, and z, In other words, f(x, y, z). How can I do that? x, y, z, and f(x, y, z) are variables that are eventually made of 10 by 10 by 10, for example:
x = 0.1:0.01:0.19;
y = 0.1:0.01:0.19;
z = 0.1:0.01:0.19;
f = x.*exp(x.^2 + y.^2 + z.^2);
I tried doing this and it failed:
[X, Y, Z] = meshgrid(x, y, z);
surf(X, Y, Z, f);
colorbar;

Risposta accettata

KSSV
KSSV il 14 Ott 2021
x = 0.1:0.01:0.19;
y = 0.1:0.01:0.19;
z = 0.1:0.01:0.19;
[x,y,z] = meshgrid(x,y,z) ;
f = x.*exp(x.^2 + y.^2 + z.^2);
figure
hold on
for i = 1:size(x,3)
surf(x(:,:,i),y(:,:,i),z(:,:,i),f(:,:,i))
end
view(3)
shading interp
And the use isosurface, slice. Read about them.
  1 Commento
Kevin Holly
Kevin Holly il 14 Ott 2021
ah, you beat me and had a better result
x = 0.1:0.01:0.19;
y = 0.1:0.01:0.19;
z = 0.1:0.01:0.19;
[X, Y, Z] = meshgrid(x, y, z);
f = X.*exp(X.^2 + Y.^2 + Z.^2);
slice(f,5,5,5)
colorbar

Accedi per commentare.

Più risposte (0)

Categorie

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

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by