+ Reply to Thread
Results 1 to 15 of 15

Extract part of matrix

  1. #1
    Registered User
    Join Date
    08-29-2018
    Location
    Delft
    MS-Off Ver
    Excel 2013
    Posts
    8

    Extract part of matrix

    Dear all,

    I have a question on how to extract a part of a matrix. The following is the case: I have a square matrix and need to extract multiple rows and columns of that matrix. For instance, I have a 5 x 5 matrix and need to extract the 2nd and 4th rows and columns to create another 2 x 2 matrix (as depicted in the figure below). What excel function should i use to obtain this result?

    matrix.png

    Thanks in advance!

    Michiel
    Last edited by Michielb; 08-29-2018 at 07:14 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    One possibility, using OFFSET:

    =OFFSET($C$5,1+2*(ROWS($1:1)-1),1+2*(COLUMNS($A:A)-1),,)
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    A better (non-volatile) alternative:

    =INDEX($C$5:$G$9,2*ROWS($1:1),2*COLUMNS($A:A))

  4. #4
    Registered User
    Join Date
    08-29-2018
    Location
    Delft
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Extract part of matrix

    Ha Glenn,

    Thank you for your fast reply! Is it also possible to have the same result but with a vector as input? So it would be possible to easily change the extracted rows and columns?

    Michiel

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    I'm not sure if I follow your request? run that past me again... only more slowly!! Think 10-year old.

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,617

    Re: Extract part of matrix

    You mean something like 2nd and 4th element from vector?

    Either for horizontal:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    or for vertical
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  7. #7
    Registered User
    Join Date
    08-29-2018
    Location
    Delft
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Extract part of matrix

    I'm sorry I wasn't completely clear. Hopefully the sheet in the attachment clarifies some things. Thanks again!
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    Spot on for an explanation for a 10-year old... and me.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-29-2018
    Location
    Delft
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Extract part of matrix

    That is about it! Do you know a way to enter this in an efficient way? I mean, I have to apply this to an 18 x 18 matrix and extract up to 16 rows and columns from it, it would be a lot of work to type the function for each cell in the matrix.

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    So, for a more complicated matrix, please post a sample sheet.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    One last guess....

    =INDEX($C$5:$G$9,CHOOSE(ROWS($1:1),$B$16,$B$17),CHOOSE(COLUMNS($A:A),$B$16,$B$17))

  12. #12
    Registered User
    Join Date
    08-29-2018
    Location
    Delft
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Extract part of matrix

    See the sample sheet in the attachment.
    Attached Files Attached Files

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    I am HOPING that the shading in your source data is irrelevant. I can't see any logical connection between it and "input".

    So, one Named range (Input):

    =Sheet1!$B$24:INDEX(Sheet1!$B$24:$B$50,COUNTA(Sheet1!$B$24:$B$50))

    and one formula copied across and dnown:
    =IFERROR(INDEX($B$2:$S$19,AGGREGATE(15,6,Input,ROWS($1:1)),AGGREGATE(15,6,Input,COLUMNS($A:A))),"")

    see sheet.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    08-29-2018
    Location
    Delft
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: Extract part of matrix

    Perfect, thank you so much for your help!

    Michiel

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Extract part of matrix

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] extract data that is not repeated within this matrix
    By marreco in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-08-2012, 05:36 PM
  2. extract data from a matrix dataset in excel
    By vamshi.lucky in forum Excel General
    Replies: 2
    Last Post: 09-12-2011, 07:09 AM
  3. Replies: 2
    Last Post: 06-14-2010, 08:39 PM
  4. Extract Data from Matrix
    By woebegone in forum Excel General
    Replies: 12
    Last Post: 08-08-2008, 04:33 PM
  5. Extract Part of String
    By [email protected] in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. Extract Part of String
    By [email protected] in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  7. Recreate the upper part of a symetric data matrix 75x75
    By Michael Cantinotti in forum Excel General
    Replies: 4
    Last Post: 05-23-2005, 12:06 PM
  8. Matrix Query Part II - lookup value
    By Krista F in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-06-2005, 10:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1