extract numbers from time series

조회 수: 2 (최근 30일)
Johannes Deelstra
Johannes Deelstra 2018년 8월 13일
댓글: Johannes Deelstra 2018년 8월 13일
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일
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일
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일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by