Eliminate all rows with '\N' element in a cell
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
This is a simple question, but I'm getting confused cuz of the different datatypes in cell
I have Cell_A (attached). I want to find the indices (row numbers) of those rows which contain '\N' in the third column. How can it be done? When these indices are found, I also want to eliminate those rows. Ultimately, I want a matrix which contains the first column of elements and the corresponding third column of elements. (with the rows containing \N eliminated).
Result = 
[10358  15
11198  31
11416  56
11426  9
11434  50
11441  44
11442  50
11444  10
11446  56];
The index output should be "4" since the fourth row contains '\N'.
This is what I have done till now.....I'm facing a problem since datatypes don't match.
Data = Tst_sorted;
Img_num = str2double(Data(:,1));
Img_class = Data(:,3);
0 件のコメント
回答 (1 件)
  KSSV
      
      
 2016 年 12 月 16 日
        load cell_A.mat
k = Cell_A ;
k = [k(:,1) k(:,3)] ;
iwant = [] ;
for i = 1:length(k)
    if ~strcmp(k(i,2),{'\N'})
        iwant = [iwant ; str2num(k{i,1}) k{i,2}];
    end
end
There will be more elegant way..
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Data Type Conversion についてさらに検索
			
	製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

