grouping observations according to strng dates with no empties

1 回表示 (過去 30 日間)
antonet
antonet 2012 年 5 月 28 日
Dear all,
I have the following matrix named mdata1
OCT 2008' [NaN] [1.4574] [0.4591]
'NOV 2008' [NaN] [1.6081] [0.4998]
'DEC 2008' [NaN] [1.6766] [0.5116]
'JAN 2009' [NaN] [1.5795] [0.4760]
'FEB 2009' [NaN] [1.4387] [0.4379]
'MAR 2009' [NaN] [1.5567] [0.4614]
'APR 2009' [NaN] [1.6339] [0.4978]
'MAY 2009' [NaN] [1.6352] [0.5041]
'JUN 2009' [NaN] [1.7392] [0.5357]
'JUL 2009' [NaN] [1.5257] [0.4884]
'AUG 2009' [NaN] [1.7156] [0.5492]
'SEP 2009' [NaN] [1.6875] [0.5429]
'OCT 2009' [NaN] [1.4765] [0.4690]
'NOV 2009' [NaN] [1.5286] [0.4912]
'DEC 2009' [NaN] [1.5641] [0.5064]
'JAN 2010' [NaN] [1.5505] [0.4984]
'FEB 2010' [NaN] [1.6991] [0.4876]
'MAR 2010' [NaN] [1.6404] [0.4765]
'APR 2010' [NaN] [1.6155] [0.4783]
'MAY 2010' [NaN] [1.6134] [0.4773]
'JUN 2010' [NaN] [1.6587] [0.4810]
'JUL 2010' [NaN] [1.7085] [0.4907]
'AUG 2010' [NaN] [1.8470] [0.5257]
'SEP 2010' [NaN] [1.9507] [0.5615]
'OCT 2010' [NaN] [1.9028] [0.5447]
'NOV 2010' [NaN] [1.9179] [0.5291]
'DEC 2010' [NaN] [1.9390] [0.5459]
'JAN 2011' [NaN] [2.1162] [0.5763]
'FEB 2011' [NaN] [2.1370] [0.5751]
'MAR 2011' [NaN] [2.2240] [0.5968]
And I want to group all the observations that correspond to ' OCT 2008' , then all the observations that correspond to 'NOV 2008' , then all the observations that correspond to 'DEC 2008' and so forth . Similarly for the years 2009, 2010 and 2011
I am trying to use a code similar to the below one
[trash idx] = sortrows([cat(7,mdata1{:,1})datenum(mdata1(:,11),'mmm yyyy')],[2 1]);
zoi= mdata1(idx,:);
but I do not know how to fix it
  2 件のコメント
Oleg Komarov
Oleg Komarov 2012 年 5 月 28 日
You have one observation for Oct 2008, Nov 2008 etc... Grouping involves multiple observations per group.
Please clarify or post an example of the desired output.
antonet
antonet 2012 年 5 月 28 日
sorry. here is a more anallytical example
the mdata1 is
' OCT 2008' [NaN] [1.4574] [0.4591]
'NOV 2008' [NaN] [1.6081] [0.4998]
'DEC 2008' [NaN] [1.6766] [0.5116]
'JAN 2009' [NaN] [1.5795] [0.4760]
'FEB 2009' [NaN] [1.4387] [0.4379
'MAR 2009' [NaN] [1.5567] [0.4614]
'APR 2009' [NaN] [1.6339] [0.4978]
'MAY 2009' [NaN] [1.6352] [0.5041]
'JUN 2009' [NaN] [1.7392] [0.5357]
'JUL 2009' [NaN] [1.5257] [0.4884]
'AUG 2009' [NaN] [1.7156] [0.5492]
'SEP 2009' [NaN] [1.6875] [0.5429]
'OCT 2009' [NaN] [1.4765] [0.4690]
'NOV 2009' [NaN] [1.5286] [0.4912]
'DEC 2009' [NaN] [1.5641] [0.5064]
'JAN 2010' [NaN] [1.5505] [0.4984]
'FEB 2010' [NaN] [1.6991] [0.4876]
'MAR 2010' [NaN] [1.6404] [0.4765]
'APR 2010' [NaN] [1.6155] [0.4783]
'MAY 2010' [NaN] [1.6134] [0.4773]
'JUN 2010' [NaN] [1.6587] [0.4810]
'JUL 2010' [NaN] [1.7085] [0.4907]
'AUG 2010' [NaN] [1.8470] [0.5257]
'SEP 2010' [NaN] [1.9507] [0.5615]
'OCT 2010' [NaN] [1.9028] [0.5447]
'NOV 2010' [NaN] [1.9179] [0.5291]
'DEC 2010' [NaN] [1.9390] [0.5459]
'JAN 2011' [NaN] [2.1162] [0.5763]
'FEB 2011' [NaN] [2.1370] [0.5751]
'MAR 2011' [NaN] [2.2240] [0.5968]
'APR 2011' [NaN] [2.1615] [0.5916]
'MAY 2011' [NaN] [2.2405] [0.6126]
'JUN 2011' [NaN] [2.2582] [0.6121]
'JUL 2011' [NaN] [2.3200] [0.5917]
'AUG 2011' [NaN] [2.2583] [0.6047]
'SEP 2011' [NaN] [2.3423] [0.6036]
' OCT 2008' [NaN] [1.8976] [0.5820]
'NOV 2008' [NaN] [1.9105] [0.5838]
'DEC 2008' [NaN] [1.8548] [0.5572]
'JAN 2009' [NaN] [1.7878] [0.5242]
'FEB 2009' [NaN] [1.8105] [0.5245]
'MAR 2009' [NaN] [1.8492] [0.5244]
'APR 2009' [NaN] [1.9462] [0.5759]
'MAY 2009' [NaN] [1.9735] [0.5927]
'JUN 2009' [NaN] [2.0056] [0.6055]
'JUL 2009' [NaN] [2.0460] [0.6414]
'AUG 2009' [NaN] [2.0569] [0.6599]
'SEP 2009' [NaN] [2.0443] [0.6570]
'OCT 2009' [NaN] [2.0401] [0.6456]
'NOV 2009' [NaN] [2.0962] [0.6603]
'DEC 2009' [NaN] [2.1124] [0.6713]
'JAN 2010' [NaN] [2.1107] [0.6626]
'FEB 2010' [NaN] [2.3077] [0.6038]
'MAR 2010' [NaN] [2.2798] [0.6041]
'APR 2010' [NaN] [2.2452] [0.6106]
'MAY 2010' [NaN] [2.2582] [0.6090]
'JUN 2010' [NaN] [2.3055] [0.6097]
'JUL 2010' [NaN] [2.4170] [0.6137]
'AUG 2010' [NaN] [2.7390] [0.6774]
'SEP 2010' [NaN] [2.8740] [0.7277]
'OCT 2010' [NaN] [2.8394] [0.7278]
'NOV 2010' [NaN] [2.9011] [0.7373]
'DEC 2010' [NaN] [2.9125] [0.7368]
'JAN 2011' [NaN] [2.9250] [0.7337]
'FEB 2011' [NaN] [2.8107] [0.7263]
'MAR 2011' [NaN] [2.8901] [0.7377]
'APR 2011' [NaN] [2.8726] [0.7544]
'MAY 2011' [NaN] [2.9381] [0.7720]
'JUN 2011' [NaN] [3.0149] [0.7760]
'JUL 2011' [NaN] [3.0806] [0.7180]
'AUG 2011' [NaN] [2.9764] [0.7958]
'SEP 2011' [NaN] [3.1679] [0.7381]
' OCT 2008' [ 3] [1.9415] [0.6472]
Now I have multiple observationd for each month. I want to group all the observations that corrspond to month OCT 2008' , then all the observations that to month 'DEC 2008' amd so forth. I hope to be more explicit this time
thanks

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

採用された回答

Thomas
Thomas 2012 年 5 月 28 日
d=datenum(mdata1(:,1),'mmm yyyy');
[thrash,idx]=sortrows(d);
mdata1(idx,:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by