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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:40:06+00:00 2026-06-05T17:40:06+00:00

Consider having a matrix. From this matrix I select the same number of elements

  • 0

Consider having a matrix. From this matrix I select the same number of elements from every row. Let us say that the matrix is nxn and from each row I take m elements (m<n).

I will build a mxm matrix with this selected elements. In every row I put the elements taken from the original matrix (same row index of course).

What is the best way to achieve this?

Thankyou

  • 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-05T17:40:08+00:00Added an answer on June 5, 2026 at 5:40 pm

    One way to achieve this is illustrated here. Define an array a to play around with …

    a = randi(6,6);
    b = a([1 3 5],[2 4 6])
    

    This demonstrates the use of index vectors for selecting rows and columns from one matrix into another. It depends on being able to specify the vectors you want to use as indices. You could also write:

    c = a(1:2:end,2:2:end)
    

    Now, if you tell us what you mean by ‘the best way’ we may be able to tell you that too !

    EDIT

    So I read the question again, it seems by ‘best’ you mean ‘fastest’. I’ve never been concerned to measure the speed of this sort of operation, I await with interest one of the real Matlab experts who lurk hereabouts providing a much cleverer answer than this.

    Of course, the fastest way is to not build a submatrix at all, but to operate on the elements of the original matrix. Whether your algorithm can be adapted to avoid building a submatrix is unknown to me.

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

Sidebar

Related Questions

Let's consider this dictionary >>> test = {'to have': True, 'to get': False, 'having':
Please consider this site . I'm having trouble stretching the submenu list items in
Consider this scenario. I have my own website, that I use as my identifier,
consider the following pgSQL statement: SELECT DISTINCT some_field FROM some_table WHERE some_field LIKE 'text%'
I am trying to do a transformation like this. Consider I am having a
Consider that I am having the following location points in google maps: Latitude point:
Consider having a 3D matrix in matlab where A(:,:,1) = [1 2 3;4 5
I've been having this strange problem with apply lately. Consider the following example: set.seed(42)
I am having problem understanding Priority Inversion Snippet from the article: Consider there is
I'm having a hard time understanding this. Consider the following example: protected void Page_Load(object

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.