Create new variable considering specific rows & columns of a cell-array
古いコメントを表示
I have a cell-array firstly composed by row 1 with years and column 1 (Y) with un-repeated values. To each element of the first column (y) correspond several codes that may change with time or even not be available (NaN). For example:
Input={ Y 2000 2001 2002 2003 2004 2005 2006 2007 2008
1 NaN NaN 33 33 33 33 33 NaN NaN
5 NaN 2 2 NaN NaN 2 64 64 64
13 NaN NaN NaN NaN NaN NaN 765 765 765};
I am trying to obtain a new variable that gives me for each value in column 1 (Y) the first and last years (row 1) in wich you observe a code. For example:
Output={ Y Start End Start2 End2
1 2002 2006
5 2001 2002 2005 2008
13 2006 2008 };
In case there are interruptions (row 3 of Input) I would like to consider extra columns (Start2 and End 2, row 3 of Output) that identify the years in which there is a code for the value in column 1 (Y).
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!