Taking outer product of two matrices
Afficher commentaires plus anciens
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 commentaires
Rik
le 13 Juil 2024
What did you try? Did you Google this?
Jatin
le 15 Juil 2024
Hi, this can be done with a basic code in MATLAB, to help you get started with MATLAB here is the documentation : Get Started with MATLAB (mathworks.com)
Umar
le 15 Juil 2024
Hi Priyanshu,
In order to help you out with your code, I will first generate a random 3x3 displacement matrix u using the rand function.Then, define the identity matrix I using the eye function and a simple gradient operator grad_op for demonstration purposes. Afterwards, I will use displacement gradient tensor F which is calculated using the formula F = I + grad_op * u. Finally, display the calculated displacement gradient tensor F using the disp function. Please see attached results.

Priyanshu
le 15 Juil 2024
Priyanshu
le 15 Juil 2024
Umar
le 15 Juil 2024
Modifié(e) : Walter Roberson
le 15 Juil 2024
Hi Priyanshu,
The outer product operation between ∇ and u can be achieved using element-wise multiplication along the third dimension. For more information on element wise multiplication, please refer to https://www.mathworks.com/support/search.html/answers/174970-element-wise-multiplication-beginner.html?fq%5B%5D=asset_type_name:answer&fq%5B%5D=category:support/matrix-in380&page=1
Here is an example snippet code to achieve this:
outer_product = zeros(3,3,3);
for i = 1:3
for j = 1:3
outer_poduct(:,:,i) = outer_product(:,:,i) + grad_op(:,:,j) * u(j,i);
end
end
This should help resolve your problem now. Please let me know if you have any further questions.
@Umar: that is true for vectors, which is what most beginners learn about. However the outer product is also defined for arrays (i.e. tensors) of arbitrary dimensions:
Applying a simple matrix multiplication to such tensors would either throw an error or give an incorrect output.
Priyanshu
le 15 Juil 2024
Umar
le 15 Juil 2024
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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!