Efficient Method for Constructing Matrix of Products in MATLAB?

In summary, the conversation discusses constructing a matrix of products using two vectors and the more efficient way to do so. It is mentioned that the ' symbol represents transposed conjugate and that MATLAB was created for matrix multiplication.
  • #1
member 428835
Suppose we have two vectors ##a = [1,2,3]## and ##b = [4,5]##. I want to construct the matrix of products, i.e. $$
\begin{bmatrix}
1\cdot 4 && 1\cdot 5\\
2\cdot 4 && 2\cdot 5\\
3\cdot 4 && 3\cdot 5
\end{bmatrix} =
\begin{bmatrix}
4 && 5\\
8 && 10\\
12 && 15
\end{bmatrix}
$$
Does anyone know an efficient way to do this?
 
Physics news on Phys.org
  • #2
Code:
a' * b
 
  • Like
Likes member 428835
  • #3
Orodruin said:
Code:
a' * b
Sweet! I was about to write a loop but thought there must be a more efficient way. Thanks! And bummer, if you hadn't used the code template that may have been the shortest character answer in the history of PF!
 
  • #4
It is just regular matrix multiplication. The ' represents the transposed conjugate and so it becomes
$$
\begin{pmatrix}1\\ 2\\ 3\end{pmatrix}
\begin{pmatrix}4& 5\end{pmatrix}
$$
which is what you wanted. MATLAB was constructed for matrix multiplication and manipulation (MATrix LABoratory).
 
  • #5
Orodruin said:
It is just regular matrix multiplication. The ' represents the transposed conjugate and so it becomes
$$
\begin{pmatrix}1\\ 2\\ 3\end{pmatrix}
\begin{pmatrix}4& 5\end{pmatrix}
$$
which is what you wanted. Matlab was constructed for matrix multiplication.
Yep, I totally agree! Maybe my last response was ambiguous; I wasn't asking about your first response, I was complementing how simple it was.
 

Related to Efficient Method for Constructing Matrix of Products in MATLAB?

1. What is vector multiplication in MATLAB?

Vector multiplication in MATLAB refers to the process of multiplying two vectors together to create a new vector. It is used to perform various mathematical operations on vectors, such as finding dot products, cross products, and element-wise multiplication.

2. How do I perform vector multiplication in MATLAB?

To perform vector multiplication in MATLAB, you can use the '*' operator. For example, to find the dot product of two vectors A and B, you can use the command: dot(A,B). To find the cross product, you can use the command: cross(A,B). And for element-wise multiplication, you can use the command: A.*B.

3. What is the difference between dot product and cross product in MATLAB?

The dot product in MATLAB calculates the scalar value resulting from the multiplication of two vectors. It is denoted by the symbol '·' or by using the dot() function. On the other hand, the cross product in MATLAB calculates the vector resulting from the multiplication of two vectors. It is denoted by the symbol 'x' or by using the cross() function.

4. Can I multiply a vector with a scalar in MATLAB?

Yes, you can multiply a vector with a scalar in MATLAB. The scalar value will be multiplied to each element in the vector, resulting in a new vector with the same dimensions as the original vector.

5. What is element-wise multiplication in MATLAB?

Element-wise multiplication in MATLAB refers to the process of multiplying corresponding elements in two vectors or matrices. It is denoted by the symbol '.*' and is used to perform operations on vectors or matrices with the same dimensions.

Similar threads

Replies
2
Views
445
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Replies
27
Views
1K
Replies
24
Views
1K
  • Linear and Abstract Algebra
Replies
4
Views
1K
  • Linear and Abstract Algebra
Replies
6
Views
1K
  • Quantum Physics
2
Replies
43
Views
2K
Replies
12
Views
1K
  • Differential Equations
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
5
Views
979
Back
Top