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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:30:40+00:00 2026-06-13T16:30:40+00:00

Is there a smart way grab Values from a 2d Array in Pairs and

  • 0

Is there a smart way grab Values from a 2d Array in Pairs and additionally to that the last number in the row?

My Data (saved in a file) look something similar to this:

  0  89  27 100  42  75 8  
  0 100   7  92   5  68 6  
  0  67  49  83 100 100 2  
 35  76  57 100 100  92 5  
 18  68  50  54 100  19 3  

After loading this Data into Matlab I need to group up the Data into Tuples by always taking the Pairs. In this Example it would be:

[0,89],[27,100],[42,75],[0,100],…[100,19]

After the pairing the Data (or meanwhile), I need to add the last Number in the row to the Pairs. The Previous mentioned Data would be altered followingly:

[0,89,8],[27,100,8],[42,75,8],[0,100,6],…[100,19,3]

How would be a smart way to solve this? I personally dislike the extensive use of Loops and think there is a nicer 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-06-13T16:30:42+00:00Added an answer on June 13, 2026 at 4:30 pm

    Edit: This should do the trick.

    M=[0  89  27 100  42  75 8  
      0 100   7  92   5  68 6  
      0  67  49  83 100 100 2  
     35  76  57 100 100  92 5  
     18  68  50  54 100  19 3]
    
    X = M(:,1:end-1)
    Y = M(:,end)
    idxOdd = mod(1:size(X,2),2)==1
    Xeven=X(:,~idxOdd)
    Xodd=X(:,idxOdd)
    
    Yrep = repmat(Y,1,sum(idxOdd))
    
    [Xodd(:) Xeven(:) Yrep(:)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an smart way of unqualifing (clean namespaces references) a XML in c#?
Is there any smart way to write a list comprehension over more than one
Is there any way to start foobar.js WSH-script in order that standard Task Manager
Is there a way to get the Tortoisehg repository explorer to start from a
Im trying to grab all data(text) coming from a URL which is constantly sending
Is there a way to grab the function name and file name when I'm
Is there some window variable in javascript that I can use or a way
Is there any smart way to do this? If using Linq2Nhibernate , you really
Is there some smart way to retreive the installation path when working within a
Is there a good way to start at a given index and move BACKWARDS

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.