フィルターのクリア

How to remove specific rows

3 ビュー (過去 30 日間)
주희 박
주희 박 2022 年 3 月 14 日
編集済み: KSSV 2022 年 3 月 14 日
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.

採用された回答

KSSV
KSSV 2022 年 3 月 14 日
編集済み: KSSV 2022 年 3 月 14 日
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 件)

カテゴリ

Help Center および File ExchangeSignal Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by