Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.6K Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Extracting a list from each nxn matrix from a set of matrices

Posted 3 years ago
POSTED BY: Nomsa Ledwaba
5 Replies
Posted 3 years ago

To get the second row from each matrix, you can do this:

StructureConstantsList[[All, 2]]

I don't understand anything after "Finally"

POSTED BY: Eric Rimbey
Posted 3 years ago

Hello. Thank you for responding.

The command you suggested does not output the 2nd row. It outputs the whole 2nd row, a list (which it is a 6x6 matrix in MatrixForm) in a set of lists. I also used the following commands and got the same outputs:

StructureConstantsList[[2, ;;]]
StructureConstantsList[[ 2, All]]
Take[StructureConstantsList, 2]
Part[StructureConstantsList, 2]

May you please advise further.

POSTED BY: Nomsa Ledwaba
Posted 3 years ago
POSTED BY: Eric Rimbey
Posted 3 years ago
POSTED BY: Nomsa Ledwaba
Posted 3 years ago

Well, I suppose I could write that up, but you don't need to specify the number of sub-matrices in your argument. It will work for any number.

StructureConstantsList = ArrayReshape[PadRight[Alphabet[], 5 3^2, Alphabet[]], {5, 3, 3}];
StructureConstantsList[[All, 2]]
(* {{"d", "e", "f"}, {"m", "n", "o"}, {"v", "w", "x"}, {"e", "f", "g"}, {"n", "o", "p"}} *)

StructureConstantsList = ArrayReshape[PadRight[Alphabet[], 1 3^2, Alphabet[]], {1, 3, 3}];
StructureConstantsList[[All, 2]]
(* {{"d", "e", "f"}} *)

If what you want is a function that takes the lists of matrices as an argument, you can do that easily:

#[[All, 2]] &

Or are you saying that you want the index of the row to be an argument?

RowsByIndex[listOfMatrices_, index_] := listOfMatrices[[All, index]]
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard