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

  • Home
  • SEARCH
  • 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 7559251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:35:26+00:00 2026-05-30T12:35:26+00:00

Background Expanding upon this question. I have a collection of points (in a three

  • 0

Background

Expanding upon this question. I have a collection of points (in a three axes system, so with (x,y,z) coordinates), and i want to calculate the distance between each point.

For that i first have to make a matrix with all possible combinations of points (preferably without duplicates, to save on processing time), to then calculate all the distances.

Problem

Now I am trying to use meshgrid for this, but it’s getting pretty complicated. It’s getting complicated because the (x,y,z) coordinates are in a matrix that is formatted as: pointCoordinates[x,y,z,pointnumber]

And i don’t know how to tell meshgrid to just combine point-1 and point-2 etc., without also combining all the separate x-coordinates with all the separate y-coordinates, etc. (wich are far too many combinations, most of which are useless).

Question

How do i keep meshgrid from making redundant combinations of coordinates? Or is there a simpler way to do this?


I guess i could reformat the pointCoordinates matrix to a simple string array points (with as many entries as there are coordinates). Where entry one is (1,3,5), entry two (2,4,2), etc. Thereby keeping the coordinates together, and limiting the number of possible combinations. But that seems redundant.

  • 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-05-30T12:35:27+00:00Added an answer on May 30, 2026 at 12:35 pm

    There is indeed a simpler way. If you only want to calculate non-redundant points, you can use pdist. Note that you can choose a different distance metric than Euclidean.

    distances = pdist(pointCoordinates(:,1:3));
    

    From the help:

    The output D is arranged in the order of ((2,1),(3,1),…, (m,1),(3,2),…(m,2),…..(m,m–1)), i.e. the lower left triangle of the full m-by-m distance matrix in column order. To get the distance between the ith and jth observations (i < j), either use the formula D((i–1)*(m–i/2)+j–i), or use the helper function Z = squareform(D), which returns an m-by-m square symmetric matrix, with the (i,j) entry equal to distance between observation i and observation j.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to stop my background image from expanding my body's height,
Background : I want to create a custom VB compiler, extending the original compiler,
Background: What I need to accomplish is to remove any records in a collection
Background: I would like to dismiss a modalView that I have presented earlier and
I have a bit of a complex issue with a CSS background. Check out
I have a table with expand/collapse div elements in td. When expanding in IE9,
I'm learning android but have a pretty fair background in java so am a
Background I have a custom control that inherits from a TreeView and is modified
I have two divs stacked one above the other, with my code expanding the
I have a horizontal nav bar, and my a elements are not expanding to

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.