select and extract only some coordinates of a 3D object
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alberto Acri
le 23 Déc 2022
Commenté : Fabio Freschi
le 23 Déc 2022
I have the following .txt file (Rx3 matrix).
rabbit = importdata("rabbit.txt");
figure
plot3(rabbit(:,1), rabbit(:,2), rabbit(:,3),'k.','Markersize',5)
grid off
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
I want to be able to extract only the coordinates of some nodes such as this area:
xlim([-10 -4])
ylim([-6 0])
zlim([11 16])
2 commentaires
Fabio Freschi
le 23 Déc 2022
Do you want to use the mouse and click on each point? Or rather you want to extract the subset of nodes in the region you specified?
Réponse acceptée
Fabio Freschi
le 23 Déc 2022
Is this what you are asking?
% your code
rabbit = importdata("rabbit.txt");
figure
plot3(rabbit(:,1), rabbit(:,2), rabbit(:,3),'k.','Markersize',5)
grid off
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
% range
xRange = [-10 -4];
yRange = [-6 0];
zRange = [11 16];
% indices of points in the range
idx = rabbit(:,1) >= xRange(1) & rabbit(:,1) <= xRange(2) & ...
rabbit(:,2) >= yRange(1) & rabbit(:,2) <= yRange(2) & ...
rabbit(:,3) >= zRange(1) & rabbit(:,3) <= zRange(2);
% plot in red
hold on
plot3(rabbit(idx,1), rabbit(idx,2), rabbit(idx,3),'ro','Markersize',5)
2 commentaires
Fabio Freschi
le 23 Déc 2022
Sure! Simply get the coordinates that were plotted
rabbithead = [rabbit(idx,1), rabbit(idx,2), rabbit(idx,3)];
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots 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!