I have a matrix which size is ,
A= 256x256x31;
And another Matrix (4D) ;
B=2031616x64 [ 4D format is : ( 256x256x31)x64]
I need to multiply matrix A with Matrix B . For the above scenario it will be not possible as dimension is not matching.
Can any one help so that the size of B becomes the size of A so that I can multiply them .
I tried with the squeeze but nothinh is happening there. So, little but confused.

 채택된 답변

Walter Roberson
Walter Roberson 2021년 9월 16일

0 개 추천

C = A .* reshape(B, size(A,1), size(A,2), size(A,3), []);
This assumes element-by-element multiplication, not matrix multiplication.

댓글 수: 4

Amit Chakraborty
Amit Chakraborty 2021년 9월 16일
편집: Amit Chakraborty 2021년 9월 16일
@Walter Roberson, Thank you for your reply. But I am having the same error still for the following code.
"Array dimensions must match for binary array"
Code:
NN=reshape(A, size(A,1), size(A,2), size(A,3), []);
B= ones(256, 256, 31, 'single');
mul= NN.*B;
Behzad Eydiyoon
Behzad Eydiyoon 2021년 9월 16일
@Amit Chakraborty Please provide your code completely.
@Walter Roberson's answer is correct.
Your post said
B=2031616x64 [ 4D format is : ( 256x256x31)x64]
but your code says
B= ones(256, 256, 31, 'single');
which is only 2031616 elements not 2031616x64 elements.
Amit Chakraborty
Amit Chakraborty 2021년 9월 16일
Thank you . It is working Now.

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

추가 답변 (0개)

카테고리

도움말 센터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!

Translated by