4d plot in order to create a surface with density from 4 vectors ( coordinates of the dots). X, Y, Z and C is the color.

10 ビュー (過去 30 日間)
Hi,
I wanto to create a 4d plot, like isosurface. The data is attached. 4 vectors, xyz and color.
The problem is that I only have 4 vectors, XYZ is position in the space which creates the object and c is the color of that point.
I am kind of lost. Maybe I need to use meshgrid but the vectors has 37k points.
Thanks

採用された回答

Akira Agata
Akira Agata 2019 年 10 月 21 日
OK. Then, how about the following?
% Load data
load('object.mat')
% Create meshgrid
[xq, yq, zq] = meshgrid(min(x):5:max(x),min(y):5:max(y),min(z):5:max(z));
% Assign data to the grid point
cq = nan(size(xq));
[~, pos] = ismember([x,y,z],[xq(:),yq(:),zq(:)],'rows');
cq(pos) = c;
% Find boundary points location
k = boundary(x,y,z,1);
% Create isosurface levels and color
N = 8;
color = jet(N);
v = linspace(min(c),max(c),N);
% Visualize the result
figure
hold on
for kk = 1:N
p = patch(isosurface(xq,yq,zq,cq,v(kk)),...
'FaceColor', color(kk,:),...
'EdgeColor', 'none',...
'FaceAlpha', 0.2);
isonormals(xq,yq,zq,cq,p)
end
trisurf(k,x,y,z,...
'Facecolor', 'b',...
'FaceAlpha', 0.1,...
'Edgecolor', 'none')
view(120,30);
camlight('headlight')
lighting gouraud
grid on
isosurface.png
  2 件のコメント
Rafael Freire
Rafael Freire 2019 年 10 月 21 日
THAT IS PERFECT!!!!!! Exactly what I needed. Thank you very very much!!!! I spent more than a week trying to solve this.
Rafael Freire
Rafael Freire 2019 年 10 月 21 日
編集済み: Rafael Freire 2019 年 10 月 21 日
BTW, many people are having the same issue. I read tons of Q&A and doubts regarding this issue during this week and all of them were unclear how solve it. Once again thank you very much. Maybe it sounds good to create a topic on it."From 4d xyzc coordinates to a surface plot"

サインインしてコメントする。

その他の回答 (1 件)

Akira Agata
Akira Agata 2019 年 10 月 19 日
How about simply using scatter3 function, like:
load('object.mat')
figure
scatter3(x,y,z,[],c,'.')
colorbar
scatter3.png
  1 件のコメント
Rafael Freire
Rafael Freire 2019 年 10 月 19 日
HI.
Thank you for your answer. I arealdy tryed that but i didint work.
The final result that I need is like the pic below. objectReal.png

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by