Creating a Simple Table in Mathematica: Connecting Two Lists

  • Thread starter Thread starter Shukie
  • Start date Start date
  • Tags Tags
    Mathematica Table
Click For Summary
SUMMARY

The discussion focuses on creating a simple table in Mathematica by connecting two lists, specifically {a, b, c} and {1, 2, 3}. The solution involves using the function TableForm[{{a, 1}, {b, 2}, {c, 3}}] to display the desired output. Additionally, the user learns that lists must be formatted as matrices (e.g., {{a, b, c}}) rather than vectors to utilize functions like Transpose[] effectively. The importance of understanding the distinction between vectors and matrices in Mathematica is emphasized for successful list manipulation.

PREREQUISITES
  • Basic understanding of Mathematica syntax
  • Familiarity with list structures in Mathematica
  • Knowledge of the Transpose[] function in Mathematica
  • Experience with the TableForm[] function for displaying data
NEXT STEPS
  • Explore the Join[] function in Mathematica for combining lists
  • Learn about matrix operations in Mathematica
  • Investigate advanced table formatting options using Grid[]
  • Study the differences between vectors and matrices in Mathematica
USEFUL FOR

This discussion is beneficial for Mathematica users, particularly students and educators looking to understand list manipulation and table creation in their projects.

Shukie
Messages
91
Reaction score
0

Homework Statement



I have two lists, say {a, b, c} and {1, 2, 3}. I want to place them in a table such as this

a 1
b 2
c 3

So a will correspond to 1, b to 2, etc.

The Attempt at a Solution



I know that TableForm[{{a, 1}, {b, 2}, {c, 3}}] would give the result I need. So I need to find a way to 'connect' the elements my two lists somewhow, if that makes sense. How do I go about this?
 
Last edited:
Physics news on Phys.org
Try this out:

Join[Transpose[{{a, b, c}}], Transpose[{{x, y, z}}], 2]

you need to write your list as {{a,b,c}} instead of {a,b,c}. the first one is a matrix and the second one is a vector; in mathematica they are not just the same; and you can't apply Transpose[] to a mathematica's vector (you can by writing Transpose[{a,b,c},{1}], but that does not give the desired result). You needed to find a way to 'join' the two :-P

(please, try to answer a question I made about making tables if you can, look at my profile, thanks)
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K