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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:11:09+00:00 2026-06-11T01:11:09+00:00

I have a matrix which is a 2d array read from a text file.

  • 0

I have a matrix which is a 2d array read from a text file. Each row of text file has 3 entries. The 3rd column has values ranging from 1 to 4. And I want to separate the rows based on this value and put them into different matrix. Could you please suggest a way to do it?

  • 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-11T01:11:11+00:00Added an answer on June 11, 2026 at 1:11 am

    For an Matrix M, as you describe

    rowsContainingOne   = M( M(:,3)==1, :)
    rowsContainingTwo   = M( M(:,3)==2, :)
    rowsContainingThree = M( M(:,3)==3, :)
    rowsContainingFour  = M( M(:,3)==4, :)
    

    To see why this works, look at the results from the following portions of:

    M(:,3)              %A vector of column three
    M(:,3)==1           %A logical array, `true` where column 3 equals one
    M( M(:,3)==1, :)    %All columns (indicated by `:`) from rows where the logical array is `true`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: correlation matrix in r I have an excel sheet which has 700
I have an wrapping object array -in fact a matrix- which includes a checkbox,
I have an unmanaged 2d array ( double A** ) representing a matrix. Each
I have a boolean[][] 2D-array called matrix , which encodes a directed graph such
I have an array of arrays P, which represents a Matrix, as an array
I have a 10GB CSV file which is essentially a huge square matrix. I
I have a matrix type which contains a void* array, representing an array of
Possible Duplicates: How to subtract a vector from each row of a matrix? How
I have a 2D numpy array (i.e matrix) A which contains useful data interspread
Suppose I have a column matrix pols containing vectors of [theta, rho, z]. Which

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.