How plot 4D data?

127 次查看(过去 30 天)
Ali Almakhmari
Ali Almakhmari 2021-10-14
评论: Kevin Holly 2021-10-14
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;

采纳的回答

KSSV
KSSV 2021-10-14
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 个评论
Kevin Holly
Kevin Holly 2021-10-14
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by