How to import data with titles and plot on a plane
1 回表示 (過去 30 日間)
古いコメントを表示
I have droplet diameter and coordinates in a CSV file and I want to draw the all these points in 3d space and later project them on a 2D plane. can someone suggest how can I read this data. Thanks in advance. I'm attaching the file for reference. I'm interested only in droplet diameter and it's coordinates.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1616848/image.png)
0 件のコメント
採用された回答
Star Strider
2024 年 2 月 14 日
編集済み: Star Strider
2024 年 2 月 14 日
I am not exactly certain what you want. One way of plotting them in 3D and also projecting them on a plane is to combine a stem3 plot and a scatter3 plot —
Uz = unzip('data.zip');
% fc = fileread(Uz{1})
fidi = fopen(Uz{1},'rt');
k = 1;
while ~feof(fidi) & (k<=10)
rl{k,:} = fgetl(fidi);
k = k+1;
end
fclose(fidi);
VN = strsplit(rl{4}, ' ');
droplets = readtable(Uz{1}, 'FileType','text', 'HeaderLines',5);
droplets.Properties.VariableNames = VN(2:end-1)
figure
stem3(droplets.('X-Coord'), droplets.('Y-Coord'), droplets.('Z-Coord'), 'Marker','none')
hold on
scatter3(droplets.('X-Coord'), droplets.('Y-Coord'), droplets.('Z-Coord'), droplets.Diameter*1E5, droplets.Diameter*1E5, 'filled')
patch([xlim flip(xlim)], [[1 1]*min(ylim) [1 1]*max(ylim)], zeros(1,4), [1 1 1]*0.75, 'FaceAlpha',0.5, 'EdgeColor','none')
hold off
colormap(turbo)
xlabel('X')
ylabel('Y')
zlabel('Z')
hcb = colorbar;
hcb.Label.String = 'Droplet Diameter \times 10^5 (M)';
EDIT — (14 Feb 2024 at 13:47)
Forgot about getting the variable names for the table. Now added.
Added gray reference plane.
Added colorbar.
.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!