Get new Double Matrix from Data on a Cell Array
古いコメントを表示
I have a cell variable with 13000 rows and 11 columns. For instance:
C1 c2 c3 c4 c5 c6 c7
A={22 1988 1992 2001 2001 [] []
23 1983 1988 [] [] [] []
29 1983 1985 1988 1991 2000 2003}
C1 is a code for an individual; c2 is the year the individual first is in the sample; c3 is the year he/she leaves. C4 is the year the individual comes back to the sample; c5 is the year the individual goes off again; and so on. The sample period is from 1983 to 2013. I can have individuals that appear in one year, leave in other and never appear again; as others may be constantly on and off the sample. I am trying to get the following variable:
- A double variable with 3 rows, ordered by year, indicating for each year and for each individual the number of years the individual is in the sample in year x.
- If the indiviual leaves the period for at least one year and comes back again , I start the count from one (number of years the individual is in the sample).
- If the individual is less than 3 years in the sample don't consider it for the count .
B=[1983 23 1
1983 29 1
1984 23 2
1984 29 2
1985 23 3
1985 29 3
1986 23 4
1987 23 5
1988 22 1
1988 23 6
1988 29 1
1989 22 2
1989 29 2
1990 22 3
1990 29 3
1991 22 4
1991 29 4
1992 22 5
…
2001 29 2
2002 29 3
2003 29 4]
Can someone help me? Thank you.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!