multiplication of a 3-D matrix by a 1-D array
4 ビュー (過去 30 日間)
古いコメントを表示
I have a 3-D matrix A = rand(sz1,sz2,sz3) and a 1-D array B = rand(1,sz3).
Is there a biult-in function to do the muliplication like:
C with dimensions of (sz1,sz2,sz3)
for ii = 1:sz3
C(:,:,ii)=A(:,:,ii)*B(ii);
end
0 件のコメント
採用された回答
Stephen23
2022 年 10 月 8 日
You don't need a special kind of multiplication, you just need to match the vector orientation to the array:
C = A .* reshape(B,1,1,[])
2 件のコメント
Stephen23
2022 年 10 月 11 日
編集済み: Stephen23
2022 年 10 月 11 日
"I checked the matlab documentation for .* and did not find an answer for the question below."
The TIMES documentation states:

"In your answer, the 2 matrices have different dimensions and the element-wise multiplication works, why?"
Clicking the link given in the TIMES documentation takes you to this page:
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!