How plot 4D data?

조회 수: 132 (최근 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에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by