How to remove common row elements from matrix

3 visualizzazioni (ultimi 30 giorni)
Hello:
I have large number of arrays with mix of NaNs & numbers, for example:
NaN NaN NaN NaN NaN NaN 1973 1 15 1973 4 14 90
1979 11 3 12 22 10 1979 11 25 1980 1 5 64
1980 4 15 1 2 1 1980 4 17 1980 5 17 33
2017 10 23 5 7 2 2017 10 30 2018 6 10 231
NaN NaN NaN NaN NaN NaN 2018 1 23 2018 7 21 180
NaN NaN NaN NaN NaN NaN 2018 6 14 2018 7 21 38
2018 10 2 17 22 5 2018 10 24 2018 12 31 91
I need to identify the row-wise common datetime elements, for example, rows 5 and 6 here, where Year-month-day of cols. 10-12 are common. My desired output would be identify such common rows from each iteration and delete that particular row. For example, desired output here would be:
Nan NaN NaN NaN NaN NaN 1973 1 15 1973 4 14 90
1979 11 3 12 22 10 1979 11 25 1980 1 5 64
1980 4 15 1 2 1 1980 4 17 1980 5 17 33
2017 10 23 5 7 2 2017 10 30 2018 6 10 231
NaN NaN NaN NaN NaN NaN 2018 1 23 2018 7 21 180
2018 10 2 17 22 5 2018 10 24 2018 12 31 91
Any suggestions how to automate this operation?

Risposta accettata

dpb
dpb il 8 Lug 2020
[~,ia]=unique(A(:,10:12),'rows');
O=A(ia,:);

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by