# Determine the coordinates of the nodes forming the outermost circle

조회 수: 7 (최근 30일)
Alberto Acri 2024년 1월 17일
댓글: Dyuman Joshi 2024년 1월 17일
Hi! How can I extract only the coordinates of the nodes forming the outermost circle? The nodes are located on radius R = 4!
nodes = importdata("nodes.txt");
figure
plot3(nodes(:,1),nodes(:,2),nodes(:,3),'b.','Markersize',15);
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
##### 댓글 수: 2없음 표시없음 숨기기
Dyuman Joshi 2024년 1월 17일
If you need a general answer (considering the cases where the data points are not uniformaly spaced), using convhull would be the most fitting.
Alberto Acri 2024년 1월 17일
I will consider it!

댓글을 달려면 로그인하십시오.

### 채택된 답변

Hassaan 2024년 1월 17일
% Load the nodes data
nodes = importdata('nodes.mat');
% Define the desired radius
R = 4;
% Calculate the distance of each node from the origin in the x-y plane
distances = sqrt(nodes(:,1).^2 + nodes(:,2).^2);
% Find the indices of nodes that are close to the radius R
% You may need to adjust the tolerance depending on the precision of your data
tolerance = 0.1; % Tolerance for the radius match
outermost_indices = find(abs(distances - R) < tolerance);
% Extract the coordinates of the outermost nodes
outermost_nodes = nodes(outermost_indices, :);
% Plot all nodes
figure;
plot3(nodes(:,1), nodes(:,2), nodes(:,3), 'b.', 'Markersize', 15);
hold on;
% Highlight the outermost nodes in red
plot3(outermost_nodes(:,1), outermost_nodes(:,2), outermost_nodes(:,3), 'r.', 'Markersize', 15);
% Set axis properties
axis equal;
xlabel('x');
ylabel('y');
zlabel('z');
% Print the coordinates of the outermost nodes
disp('Coordinates of the nodes forming the outermost circle:');
disp(outermost_nodes);
% If you want to print coordinates with a label:
for i = 1:size(outermost_nodes, 1)
fprintf('Node %d: (x, y, z) = (%.4f, %.4f, %.4f)\n', i, outermost_nodes(i, 1), outermost_nodes(i, 2), outermost_nodes(i, 3));
end
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
• Technical Services and Consulting
• Embedded Systems | Firmware Developement | Simulations
• Electrical and Electronics Engineering
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Feel free to contact me.

댓글을 달려면 로그인하십시오.

### 추가 답변 (2개)

Image Analyst 2024년 1월 17일
Can you get the coordinates as a list of (x,y) locations? If so, get the convex hull with convexHull or convhull
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Dyuman Joshi 2024년 1월 17일
+1 for convhull as I mentioned in my comment.

댓글을 달려면 로그인하십시오.

Alan Stevens 2024년 1월 17일
Here's an alternative way:
nodes = importdata("nodes.mat");
figure
plot3(nodes(:,1),nodes(:,2),nodes(:,3),'b.','Markersize',15);
axis equal
xlabel('x')
ylabel('y')
zlabel('z')
r = 4;
theta = 0:2*pi/20:2*pi;
for i = 1:numel(theta)
x(i) = r*cos(theta(i));
y(i) = r*sin(theta(i));
z(i) = 3;
end
hold on
plot3(x,y,z,'ro','markersize',15)
view(0,90)

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by