Removing rows based on numerical value

I would like to remove rows from a very large array based on a column that increments from 0.00 by tenths or hundreths to very large numbers. I only want to keep the rows that have zeros in the decimal places. I'm just not sure what MATLAB function / technique to use to pull only those rows.

回答 (1 件)

dpb
dpb 2016 年 5 月 15 日
編集済み: dpb 2016 年 5 月 16 日

0 投票

Presuming "...only want to keep the rows that have zeros in the decimal places" means the integer-valued locations, then lose those not matching--
x(mod(x(:,nCol),1)~=0),:)=[];
or, conversely, keep the wanted--
x=x(mod(x(:,nCol),1)==0),:);
where nCol is the column of interest in array x
Not sure if either has any speed advantage for larger arrays or not...

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

製品

質問済み:

2016 年 5 月 15 日

編集済み:

dpb
2016 年 5 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by