Taking outer product of two matrices
124 views (last 30 days)
Show older comments
Priyanshu
on 13 Jul 2024 at 4:44
Commented: Umar
on 16 Jul 2024 at 20:14
I have a 3x3 displacement matrix (let us call it u). The displacement gradient tensor F is given by
F = I + ∇ ⊗ u
where,
I = identity matrix
∇ = gradient operator
Can someone help me code this in MATLAB?
11 Comments
Umar
on 15 Jul 2024 at 22:24
Hi @Stephen23,
I never said that my code uses element wise application. To help you understand, it is basically very simple to understand, it is attempting to calculate the outer product of two vectors which results in a matrix where the (i,j)th entry is given by the product of the ith element of u and the jth element of v. For more information regarding basic concepts of array and matrixes, please refer to https://www.mathworks.com/help/matlab/learn_matlab/matrices-and-arrays.html Again, thanks for your contribution and feedback.
Accepted Answer
Stephen23
on 15 Jul 2024 at 17:50
Edited: Stephen23
on 15 Jul 2024 at 20:44
"However, the ⊗ operator between ∇ and u isn't the simple multiplication operator *."
The Wikipedia page you linked to states "The outer product 𝑢⊗𝑣 is equivalent to a matrix multiplication 𝑢𝑣T, provided that 𝑢 is represented as a 𝑚×1 column vector and 𝑣 as a 𝑛×1 column vector (which makes 𝑣T a row vector)." So for vectors you can certainly use matrix multiplication. For higher dimension arrays you could leverage e.g. RESHAPE and TIMES ... or read the next part of my answer.
"It's the outer produt operator and hence I am finding it difficult to code it in MATLAB"
Google found this in two seconds (note: >=R2022a only):
A = rand(3,3);
B = rand(3,3);
C = tensorprod(A,B)
4 Comments
Umar
on 16 Jul 2024 at 20:14
No problem Priyanshu, glad to help you out. Please let us know if you still have any further questions, all our staff people are very knowledgeable and happy to help out.
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!