Mathematica How to Merge a Matrix and a Vector into Coordinate Pairs?

  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Coordinates Matrix
AI Thread Summary
The discussion focuses on merging a matrix and a vector in Mathematica to create a new structure where each element of the vector is paired with corresponding elements of the matrix as tuples. The original matrix is given as a 2x3 array, and the vector as a 2x1 array. The desired output format is a 2x3 matrix of tuples, where each element of the vector is combined with the elements of the matrix. Users suggest using Mathematica's array creation methods, specifically referencing the `Array` function to achieve this format. The conversation emphasizes the importance of understanding how to manipulate arrays in Mathematica for effective data representation.
member 428835
Hi PF!

Given a matrix and vector $$
\begin{bmatrix}
a & b & c\\
d & e & f
\end{bmatrix},\\
\begin{bmatrix}
1\\
2
\end{bmatrix}
$$

how can I merge the two to have something like this

$$
\begin{bmatrix}
(1,a) & (1,b) & (1,c)\\
(2,d) & (2,e) & (2,f)
\end{bmatrix}
$$
 
Physics news on Phys.org
Python has tulles and lists of lists that look like matrices. A tuple is basically an ordered collection of different items (123, 456, ‘name’).

What language are you thinking about?
 
Something like

Table[{B[[k]], A[[k, l]]}, {k, 1, 2}, {l, 1, 3}]

where B and A are your matrices.
jedishrfu said:
What language are you thinking about?
The thread tag is "Mathematica".
 
  • Like
Likes member 428835 and jedishrfu
Okay I didn’t notice that.

Here’s some Mathematica array creation methods.

https://reference.wolfram.com/language/ref/Array.html
The last one looks like it constructs something what the OP wants.

246823
 
Back
Top