Mathematica Creating Matrix from List in Mathematica

AI Thread Summary
A user sought assistance in transforming a list of numbers into a matrix format. The initial list was {1,2,3,4,5,6,7,8,9}, and the desired output was a 3x3 matrix. A solution was provided using the command "Partition[list,3]", which successfully created the matrix {{1,2,3},{4,5,6},{7,8,9}}. The user expressed gratitude for the quick response, noting that they had spent considerable time searching for a solution on other forums.
tau1777
Messages
29
Reaction score
0
Hi All,

So I've been trying to create a matrix from a list of numbers and have been unsuccessful so far. Basically I would like to change

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

into

matrix =
1 2 3
4 5 6
7 8 9

The real problem is just a much bigger matrix, but if anyone can tell me how to do this I can do the bigger problem.

Thanks so much to anyone who helps.
 
Physics news on Phys.org
In[1]:= list={1,2,3,4,5,6,7,8,9};matrix=Partition[list,3]
Out[2]= {{1,2,3},{4,5,6},{7,8,9}}
 
Thank you so much Bill. This works like charm. Can't believe I spent a day scouring other forums for this. Thanks for the very quick response time...this was starting to drive me crazy because I was convinced it was a command that I just didn't know and it was.

Thanks. Thanks. Thanks.
 

Similar threads

Replies
2
Views
2K
Replies
5
Views
3K
Replies
4
Views
2K
Replies
0
Views
2K
Replies
6
Views
4K
Replies
22
Views
3K
Replies
3
Views
2K
Replies
10
Views
2K
Replies
2
Views
2K
Back
Top