Creating Matrix from List in Mathematica

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 9K views
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.