How to import data with titles and plot on a plane
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Rohit Thokala
el 14 de Feb. de 2024
Comentada: Star Strider
el 14 de Feb. de 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.
0 comentarios
Respuesta aceptada
Star Strider
el 14 de Feb. de 2024
Editada: Star Strider
el 14 de Feb. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Simultaneous and Synchronized Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!