Creating Matrix from List in Mathematica

Click For Summary
SUMMARY

The discussion centers on creating a matrix from a list of numbers in Mathematica. The user successfully transforms the list {1,2,3,4,5,6,7,8,9} into a matrix format using the command Partition[list, 3], resulting in a 3x3 matrix. This solution effectively addresses the user's initial challenge and serves as a foundation for handling larger matrices. The prompt response from the community highlights the efficiency of using built-in functions in Mathematica.

PREREQUISITES
  • Familiarity with Mathematica syntax and commands
  • Understanding of matrix structures and dimensions
  • Knowledge of the Partition function in Mathematica
  • Basic programming skills to manipulate lists and matrices
NEXT STEPS
  • Explore advanced features of the Partition function in Mathematica
  • Learn how to manipulate larger matrices using built-in functions
  • Investigate other list manipulation functions in Mathematica
  • Study matrix operations such as addition and multiplication in Mathematica
USEFUL FOR

This discussion is beneficial for Mathematica users, data scientists, and anyone interested in matrix manipulation and list processing within the Mathematica environment.

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 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K