pointwise multiplication of sparse matrix with full array
조회 수: 2 (최근 30일)
이전 댓글 표시
How can I do this operation?
A=sparse([1 0;0 0]);
B=rand(2,2,2,2);
C=A.*B;
the only way is converting B into a sparse array with this function?
remark: A is sparse but B is not.
댓글 수: 0
채택된 답변
Torsten
2022년 12월 12일
편집: Torsten
2022년 12월 12일
rand(2,2,2,2) generates a (2x2x2x2) array for B. You cannot multiply A with such a B elementwise because the array sizes don't match.
A=sparse([1 0;0 0]);
B=rand(2,2);
C=A.*B
Or what do you expect as result for B being (2x2x2x2) ?
댓글 수: 2
Torsten
2022년 12월 12일
@Sandra Martinez comment moved here:
Yes, I know. But if A is a full matrix this is possible ( in that case matlab makes the pointwisemultiplicación of B(: , : , i,j) with A, for each i,j) The problem here is with a sparse matix and pointwise multiplication
추가 답변 (1개)
Sandra Martinez
2022년 12월 13일
댓글 수: 2
Torsten
2022년 12월 13일
The author of ndSparse (Matt J) is active in this forum.
Maybe you should open a new question where ndSparse is part of the title and ask him directly.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!