How can i find deleted rows from matrix??

x0 = [2 3 2 2 2;
2 3 2 2 2;
2 4 1 2 2;
2 4 1 2 2;
2 3 2 2 2;
2 3 2 2 2];
x0(any(x0<2,2),:) = [];
x0 = [2 3 2 2 2;
2 3 2 2 2;
2 3 2 2 2;
2 3 2 2 2];
I want to see deleted row separately i.e
2 4 1 2 2;
2 4 1 2 2;
I want to know index of x0 which deleted.

 Risposta accettata

KSSV
KSSV il 9 Mar 2016
use k = x0(any(x0<2,2),:) ;
k will be your matrix which you are going to delete.

4 Commenti

If you want to know the indices, I would do the following:
x0(any(x0<2,2),:) = NaN; % Replace with NaN
pos = find(isnan(x0)) ; % Get the position of NaN's
[i,j] = ind2sub(size(x0),pos) ; % Get the sub indices
can you tell me for
x00 =[ -45 0 15 45 90;
-45 0 15 45 90;
-45 0 15 45 90;
-45 0 15 45 90;
-45 0 15 45 90;
-45 0 15 45 90];
eliminate same rows correspond to x0.
I'm very thankful to you for your response.
Stephen23
Stephen23 il 9 Mar 2016
Modificato: Stephen23 il 9 Mar 2016
Save the index and use it:
>> idx = any(x0<2,2);
>> xdel = x0(idx,:)
xdel =
2 4 1 2 2
2 4 1 2 2
>> xnew = x0(~idx,:)
xnew =
2 3 2 2 2
2 3 2 2 2
2 3 2 2 2
2 3 2 2 2

Accedi per commentare.

Più risposte (0)

Prodotti

Tag

Richiesto:

il 9 Mar 2016

Commentato:

il 9 Mar 2016

Community Treasure Hunt

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

Start Hunting!

Translated by