How to remove specific rows
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello
I have two datas and they are corresponded. I want to delete rows which is zero value in a. And I also want to delete same rows in b(a and b are different datas so b doesn't have zero)
a=1000X1; %a = [3 5 2 0 8 6 3 3 5 1 0 5 0 3 2 1 6 0 4 3 0 .........nonregular
b=1000X1;
So first i found rows that have zero using below code
zerorows=find(a(:,1)==0);
And I know I can delete zero rows in a using below code.
a1=nonzeros(a);
Finally I want to delete a1 in b.
I've trying several methods like
b(a1,1)=[];
But nothing works.Thank you. And I can't use 'removerows' now. So I need other methods.
0 Kommentare
Akzeptierte Antwort
KSSV
am 14 Mär. 2022
Bearbeitet: KSSV
am 14 Mär. 2022
idx = a == 0 ; % find indices of zeroes in a
b(idx) = [] ; % remove the respective values from b
If a is floating point numbers (which are mostly), you should prefer using this:
tol = 10^-5 ;
idx = abs(a)<=tol ; % find indices of zeroes in a
b(idx) = [] ; % remove the respective values from b
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Signal Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!