Have a time series from 1 to 156. Want to extract the values from 1:6, then from (1+12) : (6+12), etc into a new variable. How to go about.

6 件のコメント

Adam Danz
Adam Danz 2018 年 8 月 13 日
That's not enough in your example for anyone to extrapolate the pattern you seek. For example, would the subunits be 1:6, 13:18, 14:19, 15:20? Or 1:6, 13:18, 19:24,... ?
Johannes Deelstra
Johannes Deelstra 2018 年 8 月 13 日
ok I will try to be more specific. Actually it is a matrix with monthly values. Columns 1:4 contain calcualted mean values of parameters I am interested in, while column 5 contains the months/dates from may 1992 until april 2005. Now I want from this time series for each year the values for the parameters I am interested in, which are those for the months of May until October. So how can I do this, obtain the values for the parameters in columns 1 to 4 plus the datevalues in column 5 Thanks in advance
Adam Danz
Adam Danz 2018 年 8 月 13 日
What format are your dates in?
class(data(:,5))
Johannes Deelstra
Johannes Deelstra 2018 年 8 月 13 日
the dates are numbers such as 33725 33756 33786 33817 33848 33878 33909 33939 33970 34001 34029
Adam Danz
Adam Danz 2018 年 8 月 13 日
Ok. If the numbers are serial date numbers that matlab recognizes, my solution should work well. Otherwise, we'd just need to convert them to a format that Matlab recognizes which should be fairly simple.
Johannes Deelstra
Johannes Deelstra 2018 年 8 月 13 日
i solved the problem, thanks for your help and suggestions

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

 採用された回答

Adam Danz
Adam Danz 2018 年 8 月 13 日

0 投票

I don't know what format your dates are in but this can be adapted to any format. I assume your matrix is named 'data' and the dates are in the 5th column.
% Get the month number for each date
monthNum = month(data(:,5));
% Logical index of rows that are between May and October
monthIdx = ismember(monthNum, [5:10]);
% Extract your data for these months
data(monthIdx, :)

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2018 年 8 月 13 日

0 投票

a=1:156;
b=reshape(a,6,[]);
c=b(:,1:2:end)

2 件のコメント

Johannes Deelstra
Johannes Deelstra 2018 年 8 月 13 日
see my answer to the question I got from Adam. Tried to be more specific.
Johannes Deelstra
Johannes Deelstra 2018 年 8 月 13 日
the dates are numbers, such as 33725 33756 33786 33817 33848 33878 33909 33939 33970 34001 34029

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

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

製品

リリース

R2017a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by