Mathematica Asked by PoreyS on March 19, 2021
Suppose I have a matrix ‘mat’ as
mat = Table[Subscript[m, i, j], {i, 5}, {j, 5}];
mat // MatrixForm
I want to extract the first column (or any row) as
a = mat[[All, 1]]
{Subscript[m, 1, 1], Subscript[m, 2, 1], Subscript[m, 3, 1],
Subscript[m, 4, 1], Subscript[m, 5, 1]}
But I want the output as
{{Subscript[m, 1, 1]}, {Subscript[m, 2, 1]}, {Subscript[m, 3,
1]}, {Subscript[m, 4, 1]}, {Subscript[m, 5, 1]}}
How can I do that?
a = mat[[All, {1}]]
{{Subscript[m, 1, 1]}, {Subscript[m, 2, 1]}, {Subscript[m, 3, 1]}, {Subscript[m, 4, 1]}, {Subscript[m, 5, 1]}}
MatrixForm @ a
Correct answer by kglr on March 19, 2021
Try Partition[mat[[All, 1]], 1]
.
Answered by Michael Poulshock on March 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP