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

  • Context: Mathematica 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Coordinates Matrix
Click For Summary

Discussion Overview

The discussion revolves around the problem of merging a matrix and a vector into coordinate pairs, specifically how to achieve this in programming languages like Python and Mathematica. The focus includes both theoretical understanding and practical implementation.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant presents a matrix and a vector and asks how to merge them into a specific format of coordinate pairs.
  • Another participant suggests using tuples and lists of lists in Python, indicating that tuples can hold ordered collections of items.
  • A different participant proposes a specific code snippet in Mathematica to achieve the desired merging of the matrix and vector.
  • Another reply provides a link to Mathematica's array creation methods, suggesting that one of these methods may fulfill the original request.

Areas of Agreement / Disagreement

Participants express different programming approaches and tools, but there is no consensus on a single solution or method to merge the matrix and vector as requested.

Contextual Notes

The discussion includes various programming languages and methods, but does not resolve the specifics of implementation or the assumptions behind the proposed solutions.

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   Reactions: 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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 24 ·
Replies
24
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 9 ·
Replies
9
Views
1K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K