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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:49:45+00:00 2026-05-23T23:49:45+00:00

A matrix has m rows and n columns (n being a number not exceeding

  • 0

A matrix has m rows and n columns (n being a number not exceeding 10), and the nth column contains either 1 or 0 (binary). I want to use this binary as a decision to take out the associated row (if 1, or otherwise if 0). I understand that this can be done through iteration with the use of the IF conditional.

However, this may become impractical with matrices whose number of rows m gets into the hundreds (up to 1000). What other procedures are available?

  • 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-23T23:49:47+00:00Added an answer on May 23, 2026 at 11:49 pm

    You can use logical datatypes for indexing. For example,

    M =

     1     2     0
     4     5     1
     7     8     0
    
    M = [1 2 0;4 5 1;7 8 0];
    v = (M(:,n) == 1);
    M(v,2) = 1;
    

    M =

     1     2     0
     4     1     1
     7     8     0
    

    Now you have set all the elements in column 2 to 1 if the corresponding element in column n is true.

    Note that the v = (M(:,n) == 1) converts the nth column to a logical vector. You can accomplish the same with v = logical(M(:,n));

    I would recommend this blog entry for a detailed look at logical indexing.

    Update:

    If you want to erase rows, then use:

    M(v,:) = [];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to find the number of rows and columns a matrix has without
I have a problem, user inputs number m (meaning matrix has m-rows, m-columns), then
Using NumPy , a matrix A has n rows and m columns, and I
I have a matrix that has 20 rows and 51 columns. I would like
Let's say I have a matrix x which contains 10 rows and 2 columns.
I think Mathematica is biased towards rows not columns. Given a matrix, to insert
just a quick question, if I have a matrix has n rows and m
so I want to write a matrix explorer which enables me to reorder rows
I have a matrix which has multiple rows per ID. I need to extract
I have a 2D matrix mat with 500 rows × 335 columns, and a

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.