Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7906273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:51:49+00:00 2026-06-03T10:51:49+00:00

So we have a reference set of 3D points (let’s call it R), and

  • 0

So we have a reference set of 3D points (let’s call it R), and many other sets of 3D points (let’s call that set of sets of data points P, and each data set in that Pi).

The task is to return the Pi that minimizes the euclidean distance the data points in some Pi and R. The way I see it is this:

  1. For each point in Pi, compare to each point in R and find the minimum difference between two points.
  2. Sum up these minimum distances to reach the minimum total “difference” between Pi and R.
  3. The answer Pi is the one with the smallest difference.

But this is pretty crazy, since it means essentially looking at the distance between every point in R and every point in P, which could be thousands or millions. Surely I can do better than that.

I am working in Matlab, which I am not used to.

What is a better algorithm to use? Is there a data structure that is perfect for this? (for example a K-D tree?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:51:51+00:00Added an answer on June 3, 2026 at 10:51 am

    Unless you have such a crazy amount of points that this really becomes a performance issue, comparing to every point is really the easiest solution, particularly because these operations can be highly vectorized in Matlab.

    For example:

    R = [1 2 3; 1 3 4];
    P{1} = [2 3 5;1 1 2;2 1 3];
    P{2} = [4 4 4];
    
    nP = length(P);
    sumMinDist = zeros(nP,1);
    
    %# make R into n-by-1-by-3 already
    Rperm = permute(R,[1 3 2]);
    
    for iP = 1:nP
    
    %# since we want to sum up the minima, we need to take the square root
    allDist = sqrt( sum( bsxfun(@minus, Rperm, permute(P{iP},[3 1 2])).^2, 3));
    
    %# sum the minima (you may want to consider
    %# taking the mean instead!)
    sumMinDist(iP) = sum(min(allDist,[],1));
    
    end
    
    %# now we can identify the closest set
    [~,idxOfClosestSet] = min(sumMinDist);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a reference to call that may or may not be there. When
I have parent/child relationship set up via Node Reference. A Child record can have
I have a .exe assembly and a set of referenced assemblies that I would
I have a reference table (main) of products names and a few other tables
I have a reference to System.Data in my windows service project. I keep getting
I have a reference application that I use to work through DDD issues, and
So, I currently have a Board class that is composed of Piece s. Each
Let's assume I have an unlimited hosting plan on GoDaddy that I want to
I have a data producer that produces data that is used by a number
I have some CAD software I've written. Each component being drawn has a set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.