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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:50:39+00:00 2026-06-08T05:50:39+00:00

Once again, sorry if this has been asked before and if its too specific

  • 0

Once again, sorry if this has been asked before and if its too specific but I’m very stuck and can’t quite find a solution.

I have a matrix of say 3 members of a structure called 2, 4 and 16 (in column 1) that have values along their relative distance e.g. member 2 has values at the start, 0m, then at 0.5m then the end of its length 1.5m, where member 4 starts at 0m etc. So that my matrix looks like this:

2   0     125
2   0.5   25
2   1.5   365
4   0     25
4   0.6   57
16  0     354
16  0.2   95
16  0.8   2

and I want to create a matrix that has the overall distance along all the members 2, 4 and 16 combined:

2   0     125
2   0.5   25
2   1.5   365
4   1.5   25
4   2.1   57
16  2.1   354
16  2.3   95
16  3.1   2

is there any way to do this in matlab? Like possibly locating the first zero and adding the value above it to all the rest of the values below then find the next zero value and so on?

Please tell me if this isn’t clear, I realise it’s a bit confusing but not too sure how to explain it better!

  • 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-08T05:50:43+00:00Added an answer on June 8, 2026 at 5:50 am

    I came up with the following:

    idx = find(diff(M(:,1)));
    v = zeros(size(M,1),1);
    v(idx+1) = M(idx,2);
    M(:,2) = M(:,2) + cumsum(v);
    

    The result:

    M =
                2            0          125
                2          0.5           25
                2          1.5          365
                4          1.5           25
                4          2.1           57
               16          2.1          354
               16          2.3           95
               16          2.9            2
    

    Note the last value in the second column disagrees with what you described (2.9 vs 3.1). Either you had a typo, or I’m still not getting it…

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

Sidebar

Related Questions

Ok, I know this has been asked a thousand times before, but no conclusive
Sorry if this has been answered before, but all the related questions didn't quite
Sorry to be editing this once again, but rather than make another post, I
OK.. I am sorry for asking an often asked question once again, but I
Sorry, but I can only show this problem on a live sandbox site. if
I apologize if this question has been answered already, but I cannot seem to
Once again a very beginner-ish question, but here I go: I would like to
Once again, I'm at a loss with IE7 on this one. I'm making a
Once again my silliness has struck. I would like to thank everyone who helped
Once again I'm doing Java graphics (Graphics2D) but I noticed there is no Polygon.Double

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.