Elementwise Multiplication of column of 3D-array with an 1D-array
이전 댓글 표시
Hi, I'm trying to multiply a column of an array with dimensions (3,5,3) with an 1D-array as follows:
B=rand(3,5,3);
k=0:2;
B(1,1,:).*k
Matlab tells me:
Error using .*
Matrix dimensions must agree.
However, the size of the column and the array is always 3. What's wrong with this expression?
Many thanks in advance.
채택된 답변
추가 답변 (1개)
the cyclist
2015년 6월 3일
1 개 추천
B(1,1,:) is a 1x1x3 array, and k is a 1x3 array, which could be considered a 1x3x1. Those are not actually the same.
You can use the permute function to rearrange the dimensions to get what you want.
카테고리
도움말 센터 및 File Exchange에서 Antennas, Microphones, and Sonar Transducers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!