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.
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.
.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simultaneous and Synchronized Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!