필터 지우기
필터 지우기

Matlab plot 4D data

조회 수: 4 (최근 30일)
Yi Liu
Yi Liu 2022년 10월 12일
답변: Keita Abe 2022년 10월 12일
I want to plot 4d data on space x+y+z<=1,x>=0,y>=0,z>=0, so I use the following code
i=1;
for p=0:0.01:1
for q=0:0.01:1-p
for r=0:0.01:1-p-q
[ua,ub]=BNE(p,q,r);
E(i)=ua+ub;
x(i)=p;
y(i)=q;
z(i)=r;
i=i+1;
end
end
end
[X,Y,Z]=meshgrid(x,y,z);
surf(X,Y,Z,E)
But it failed. How plot the data (x,y,z,E). Where BNE() is the self-defining function.

답변 (1개)

Keita Abe
Keita Abe 2022년 10월 12일
I found that two points for reconsindering
  • meshgrid function requires unique array of x, y, z.
  • surf function requires the surface definition but your input is volume data
If you would like to know the isosurface, I hope the following code would be helpful. Or if you would like to define the surface, the following link will be helpful. 2 次元または 3 次元の散布データの内挿 - MATLAB griddata - MathWorks 日本
i=1;
for p=0:0.01:1
for q=0:0.01:1-p
for r=0:0.01:1-p-q
[ua,ub]=BNE(p,q,r);
E(i)=ua+ub;
x(i)=p;
y(i)=q;
z(i)=r;
i=i+1;
end
end
end
[X,Y,Z]=meshgrid(unique(x),unique(y),unique(z));
vq = griddata(x,y,z,E,X,Y,Z);
isosurface(X,Y,Z,vq,0.5)
function [ua, ub] = BNE(p,q,r)
ua = p+q;
ub = q+r;
end

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by