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 7166355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:24:00+00:00 2026-05-28T14:24:00+00:00

Let Q be a nx2 vector, which contains n (2-dimensional) coordinates. I want to

  • 0

Let Q be a nx2 vector, which contains n (2-dimensional) coordinates. I want to calculate the distance between the i and i+1-th coordinate for all integers i in the vector and then add it up.

I came up with the following:

syms d

symsum(sqrt(sum((Q(d,:)-Q(d+1,:).^2))),d,1,n-1);

However, I get the following error:

??? Error using ==> sym.sym>notimplemented at 2653
Function 'subsindex' is not implemented for MuPAD symbolic objects.

Error in ==> sym.sym>sym.subsindex at 1359
            notimplemented('subsindex');

Error in ==> test4 at 4
symsum(sqrt(sum((Q(d,:)-Q(d+1,:).^2))),d,1,n-1);

Alternatively I could of course use a for loop, but I suspect that this is probably not the neatest and quickest solution.

  • 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-28T14:24:00+00:00Added an answer on May 28, 2026 at 2:24 pm

    If I am reading this correctly you just want the Euclidean distance between pairs of points in your nx2 matrix. So all you have to do is this:

    >> Q = rand(10,2)  %Define Q
    
    Q =
    
        0.6557    0.7060
        0.0357    0.0318
        0.8491    0.2769
        0.9340    0.0462
        0.6787    0.0971
        0.7577    0.8235
        0.7431    0.6948
        0.3922    0.3171
        0.6555    0.9502
        0.1712    0.0344
    
    >> distPairs =  sum(diff(Q,1,1).^2,2); %Distance between adjacent coordinates
    >> totalDist = sum(distPairs)  %Sum all of the pairwise distances.
    
    totalDist =
    
        4.0486
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have a drive such as C:\ , and I want to
Let's say I'm making a tool to help epicureans keep track of which delicacies
Let's say you have a object that is unique, and it's used by all
Let's say I want to write a function that validates an email address with
Let's say I have a dataset, which can be neatly classified using weka's J48
Let's assume I want to deserialize this (I've removed the namespaces to make things
Let's suppose I've got a 2D vector template class: template<typename T> class Vec2 {
Let simplify the question: All I need is to explode() string by a comma
Let's say I'm writing a Windows Forms (.NET Framework 3.5) application which shows the

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.