Removing Partially Identical Rows from Array sets

Hi,
after converting this file into an array of HEX numbers, I would like to supress the line where some values are the same as another line:
for exemple, i want to remove a line if all the numbers execpt for the 3rd and 5th one are identical to the numbers in another line (i want to remove the 3rd and 5th number from the comparaison process but i don't want to remove them from the array)

 採用された回答

Voss
Voss 2023 年 8 月 17 日
編集済み: Voss 2023 年 8 月 17 日

1 投票

Using Walter's code from his answer to your other question to read and interpret the file:
S = readlines('test.txt');
S(strlength(S) == 0) = []; %end of file usually comes through as empty line
SS = regexp(S, '\s+', 'split');
wanted = vertcat(SS{:})
wanted = 12×24 string array
"12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "00" "02" "23" "40" "65" "84" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "FF" "FF" "FF" "FF" "FF" "51" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF"
Now get the set of unique rows, ignoring the specified columns:
cols = [3 5];
temp = wanted;
temp(:,cols) = [];
[~,ii] = unique(temp,'rows','stable');
result = wanted(ii,:)
result = 3×24 string array
"12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "68" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "FF" "00" "02" "23" "40" "65" "84" "94" "12" "63" "67" "05" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF" "12" "AB" "5A" "00" "00" "02" "23" "40" "65" "84" "FF" "FF" "FF" "FF" "FF" "51" "49" "99" "AA" "FF" "FF" "FF" "FF" "FF"

2 件のコメント

benjamin ktorza
benjamin ktorza 2023 年 8 月 18 日
thank you for the fast answer
Voss
Voss 2023 年 8 月 18 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

製品

質問済み:

2023 年 8 月 17 日

コメント済み:

2023 年 8 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by