How to fastly calculate this real number matrix manipulation?
이전 댓글 표시
I have a matrix X with dimensional
. I want to calculate a matrix M with the same dimension as X. The element of M is calculated as follows
is the I know using for loop by extracting the element of X can obtain this matrix M but it is not efficient. Is there any other way to fastly calculate this matrix from X?
답변 (1개)
e=(1:A)';
I=reshape(e,1,1,[]) == repmat( e,1,B);
Xp=permute(X,[3,2,1]);
D=X./(X-Xp);
D(I)=1;
M = ipermute( prod(D,1) ,[3,2,1]);
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!