How to import data with titles and plot on a plane
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rohit Thokala
le 14 Fév 2024
Commenté : Star Strider
le 14 Fév 2024
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 commentaires
Réponse acceptée
Star Strider
le 14 Fév 2024
Modifié(e) : Star Strider
le 14 Fév 2024
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Simultaneous and Synchronized Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!