Taking outer product of two matrices

조회 수: 23 (최근 30일)
Priyanshu
Priyanshu 2024년 7월 13일
댓글: Umar 2024년 7월 16일
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
⊗ = outer product of two matrices,
Can someone help me code this in MATLAB?
  댓글 수: 11
Stephen23
Stephen23 2024년 7월 15일
편집: Stephen23 2024년 7월 15일
"Hence, illustrated my example with element wise multiplication."
None of your code uses element-wise multiplication.
Umar
Umar 2024년 7월 15일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2024년 7월 15일
편집: Stephen23 2024년 7월 15일
"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)
C =
C(:,:,1,1) = 0.0016 0.0022 0.0001 0.0014 0.0007 0.0031 0.0041 0.0036 0.0037 C(:,:,2,1) = 0.0300 0.0403 0.0015 0.0265 0.0136 0.0581 0.0759 0.0680 0.0701 C(:,:,3,1) = 0.1153 0.1550 0.0059 0.1018 0.0525 0.2235 0.2921 0.2617 0.2698 C(:,:,1,2) = 0.1815 0.2438 0.0093 0.1602 0.0826 0.3515 0.4596 0.4117 0.4244 C(:,:,2,2) = 0.0327 0.0440 0.0017 0.0289 0.0149 0.0634 0.0829 0.0743 0.0766 C(:,:,3,2) = 0.1576 0.2118 0.0081 0.1392 0.0717 0.3054 0.3992 0.3576 0.3687 C(:,:,1,3) = 0.1604 0.2154 0.0082 0.1416 0.0730 0.3107 0.4061 0.3638 0.3751 C(:,:,2,3) = 0.2397 0.3220 0.0123 0.2116 0.1091 0.4643 0.6070 0.5437 0.5606 C(:,:,3,3) = 0.1568 0.2107 0.0081 0.1385 0.0714 0.3038 0.3972 0.3558 0.3669
  댓글 수: 4
Priyanshu
Priyanshu 2024년 7월 16일
Thank you for helping me with the concept. I understand the logic and i think the code will be good for me.
Umar
Umar 2024년 7월 16일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by