How to fastly calculate this real number matrix manipulation?

32 ビュー (過去 30 日間)
Hancheng Zhu
Hancheng Zhu 2025 年 2 月 25 日 13:26
編集済み: Matt J 2025 年 2 月 25 日 17:04
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
, where . In this equation, is the element of the matrix M and represents the product of a bunch of factors.
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 件)

Matt J
Matt J 約4時間 前
編集済み: Matt J 約2時間 前
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]);

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by