フィルターのクリア

Erase rows of a cell based on a condition

1 回表示 (過去 30 日間)
Maria
Maria 2014 年 7 月 19 日
コメント済み: Maria 2014 年 7 月 19 日
I have a cell array with 20 000 rows (A - numbers are not repeated) and 17 columns (years). In the example below I only present 6 columns and 5 rows.
CA:
A 1997 1999 2000 2001 2002
13 189 189 39 39 39
16 183 183 183 183 183
18 76 76 76 76 28
22 [] [] [] [] 123
25 [] [] [] [] []´
I am trying to erase the rows that do not present at least two consecutive values. And in case the value changes , to get a new variable only with these specific rows.
CA:
A 1997 1999 2000 2001 2002
13 189 189 39 39 39
16 183 183 183 183 183
18 76 76 76 76 28
NEW:
A 1997 1999 2000 2001 2002
13 189 189 39 39 39
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 19 日
How did you get NEW ?

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 19 日
編集済み: Azzi Abdelmalek 2014 年 7 月 19 日
To get CA
A ={ ' A' 1997 1999 2000 2001 2002
13 189 189 39 39 39
16 183 183 183 183 183
18 76 76 76 76 28
22 [] [] [] [] 123
25 [] [] [] [] []}
B=A(2:end,:);
idx=~cellfun(@isempty,B)
B(arrayfun(@(x) isempty(strfind(idx(x,:),[1 1])),1:size(idx,1)),:)=[]
CA=[A(1,:) ;B]
It's not clear how did you get NEW
  1 件のコメント
Maria
Maria 2014 年 7 月 19 日
I am sorry for the late response. 'NEW' is just a new variable I got if I only consider the rows in which I observe a change in the values when passing from column to column. In my example it would be row 1 and 2 only. Thank you for the help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by