Putting points into groups of three to find their centers
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
For example, if I have points A, B, C, D, how would I be able to find the centers of circle ABC, ACD, ABD, and BCD?
I found a function to get the centers from circles: https://www.mathworks.com/matlabcentral/fileexchange/57668-fit-circle-through-3-points
But I do not know how to find all the combinations of three points from my data set. I thought the nchoosek function might work, but I have my data set includes both x and y values for each point and they are not intergers. Would appricate any suggestions!
댓글 수: 2
  Jan
      
      
 2022년 3월 15일
				Please post some code which defines the inputs. "points A,B,C,D" does not tell us, in which format you save the coordinates: [1 x 2], [2 x 1], fields "x" and "y" of a struct, etc.
채택된 답변
  Jan
      
      
 2022년 3월 15일
        
      편집: Jan
      
      
 2022년 3월 15일
  
      Guessing, that the "points" are [1x2] vectors:
A = [1, 12];
B = [2, 10];
C = [3, 17];
D = [4, 9];
P = cat(1, A, B, C, D);  % Much better than a set of variables!
% Now you can usen an index:
Groups = nchoosek(1:4, 3);
for k = 1:size(Gropus, 1)
    aGroup = Gropus(k, :);
    ThreeP = P(aGroup, :);  % Coordinates of 3 points as [3 x 2] matrix
    ... Do what you want with them
end
Idea: Do not create a set of variables, but store them in a matrix directly. Then it is trivial to access them using an index. 
댓글 수: 2
  Image Analyst
      
      
 2022년 3월 15일
				
      편집: Image Analyst
      
      
 2022년 3월 15일
  
			Why do just a subset of the numbers?  Why not do them all?  A hundred or more is not very large.  Even a million wouldn't be.  If you have tens of millions though, it might take a bit of time.
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
			
	제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!