Need to find dot product between two second order tensor

13 ビュー (過去 30 日間)
Ahmar Yanis
Ahmar Yanis 2022 年 10 月 4 日
編集済み: James Tursa 2022 年 10 月 4 日
Using matlab randi function to generate a (LxM) matrix S and a (MxN) matrix T. Component ranging from 0 to 9 with L,M,N> 2. Calculate R=S.T use for loop to iterate through the admissible values from indices i and j.
  2 件のコメント
James Tursa
James Tursa 2022 年 10 月 4 日
編集済み: James Tursa 2022 年 10 月 4 日
You need to provide many more details for what you are trying to do. Include a small example of inputs and desired outputs. Based on what you have written so far, I could only guess that you want S*T to give a LxN result of dot products.
Ahmar Yanis
Ahmar Yanis 2022 年 10 月 4 日
% Define the matrix that represents tensor S
S = randi([0,9],3,3)
% Define the matrix that represents vecor u
u = randi([0,9],3,3)
% Apply the dot product
for i =1:size(S,1)
for k=1:size(u,2)
w(i) = dot(S(i),u(k));
end
end
the part which i dont understand is the for loop how will i iterate

サインインしてコメントする。

回答 (1 件)

James Tursa
James Tursa 2022 年 10 月 4 日
編集済み: James Tursa 2022 年 10 月 4 日
If you change the inner loop calculation to this:
w(i,k) = dot(S(i,:),u(:,k));
then you would have dot products between the S rows and u columns. But the result of this is simply going to be the matrix product S*u as I mentioned above. I'm still not sure what you want to do. Can you give a small numeric example of inputs and desired output?

カテゴリ

Help Center および File ExchangeTime Series Events についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by