フィルターのクリア

Read a data set and bin it to different groups.

2 ビュー (過去 30 日間)
anton fernando
anton fernando 2014 年 7 月 18 日
コメント済み: anton fernando 2014 年 7 月 18 日
2004017 2004018 2004018 2006019 2004019 2004017 2004018 2004018 2005019 2004019 2004017 2004018 2004018 2008019 2004019
The first four numbers of each data give the year. I want to bin the data according to their years. How should I do that? if the year is 2004 assign it to an array T1. if the year is 2005 assign it to an array T2. So on.

採用された回答

Rick Rosson
Rick Rosson 2014 年 7 月 18 日
A = [ List of numbers ];
x = floor(A/1000);
T1 = A( x == 2004 );
T2 = ...
...
  1 件のコメント
anton fernando
anton fernando 2014 年 7 月 18 日
Thank you very much. Similarly how can I do that for the last 3 digits in the numbers. I want to read last 3 digits and bin them to intervals. If last 3 digits in between 0-5, 5-10, 10-15 so on.

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 18 日
a=[2004017 2004018 2004018 2006019 2004019 2004017 2004018 2004018 2005019 2004019 2004017 2004018 2004018 20084019 2004019]
b=arrayfun(@num2str,a,'un',0)
c=cellfun(@(x) str2num(x(1:4)),b)
[ii,jj,kk]=unique(c)
idx=arrayfun(@(x) find(ismember(c,x)),ii,'un',0)
out=cellfun(@(x) a(x),idx,'un',0)
celldisp(out)
  1 件のコメント
anton fernando
anton fernando 2014 年 7 月 18 日
Thank you. It worked.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by