Keep track of Matrix row indices after deleting some rows

4 ビュー (過去 30 日間)
Nadatimuj
Nadatimuj 2021 年 4 月 18 日
コメント済み: Nadatimuj 2021 年 4 月 18 日
Suppose, I have a 10x10 Martix A= magic(10).
Then I delete some rows from it as A([3 5 6],:)=[]. and some columns as A(:,[3 5 6])=[]
Now it's a 7x7 matrix.
I want to keep track of the indices to know which row in the orginal matrix becomes which row in the transformed matrix.
A= magic(10);
A([3 5 6],:)=[];
A(:,[3 5 6])=[];
I want to keep track that previous 4th row is now the 3rd row...previous 7th row is now the 4th row...etc. Any solid way to do that? Please help. Thanks.

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 4 月 18 日
編集済み: KALYAN ACHARJYA 2021 年 4 月 18 日
You can store the A in a temporary variable, and do the modification on temp
temp=A;
Now do the all modification on temp. Result A is original and temp is the modified matrix. Afterwards you can do the comparision between A and temp, like simmilarity
  1 件のコメント
Nadatimuj
Nadatimuj 2021 年 4 月 18 日
Hi,
Thanks for your suggestion. I actually seek help for that "comparison" part. I need to save (for further use) a mapping of new indices that can give me the corresponding old index Matrix row
for example, temp(7,:) and modified(4,:) will give me similar row...I need such index mapping. Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by