Mathematica How can I convert a matrix to a list in Mathematica?

AI Thread Summary
The discussion focuses on converting a matrix into a single list. The matrix provided is a 3x3 grid with values ranging from 1 to 9. A user seeks a solution to flatten this matrix into a list format. The solution offered is the use of the Flatten function, which effectively transforms the matrix into a list containing all the elements in a single sequence. The user expresses gratitude for this straightforward solution, noting previous attempts with methods like "For" and "Join" that were more complicated.
johnobono
Messages
2
Reaction score
0
Hi everyone:

I would like to join all elements of on matrix into just one list:

matrix =
1 2 3
4 5 6
7 8 9

into

list = {1,2,3,4,5,6,7,8,9}

Anyone has a solution for this?

Thanks
 
Physics news on Phys.org
list = Flatten[matrix]
 
  • Like
Likes johnobono
OMG! Thanks, such a simple solution. I tried a lot of things, such as "For" and "Join", but with no easy result.

Thank you very much!
 

Similar threads

Replies
5
Views
3K
Replies
4
Views
2K
Replies
2
Views
1K
Replies
2
Views
9K
Replies
19
Views
2K
Replies
6
Views
4K
Replies
2
Views
2K
Back
Top