Can someone assist please:

댓글 수: 1

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 14일
편집: Azzi Abdelmalek 2015년 7월 14일
Do you mean for the first week of each month or of what? can you give more details about your first column?

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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 7월 14일
편집: Andrei Bobrov 2015년 7월 15일

1 개 추천

% data - your data; first column - data+time, second - Power
data = [timeprac1,P];
v = datevec(data(:,1));
a = datenum(unique(v(ismember(v(:,[2,3]),[1 1],'rows'),[1:3]),'rows'));
z = weekday(a);
dd = bsxfun(@minus,2:8,z - a)';
[lo,ii] = ismember(fix(data(:,1)),dd(:));
ii = ceil(ii/7);
out = accumarray(ii(lo),data(lo,2),[],@(x){[mean(x),max(x)]});
add variant, if "first week" - 1-7 January
v = datevec(timeprac1);
lo = v(:,2) == 1 & ceil(v(:,3)/7) == 1;
[a,~,c] = unique(v(lo,1));
out1 = accumarray(c,P(lo),[],@(x){[mean(x),max(x)]});
out = [a, cell2mat(out)];
third variant, here "first week" - first full week (Mon-Sun) each year's
v = datevec(timeprac1);
a = datenum(unique(v(ismember(v(:,[2,3]),[1 1],'rows'),[1:3]),'rows'));
z = weekday(a);
dd = bsxfun(@plus,a + 9 - z,0:6);
[lo,ii] = ismember(fix(timeprac1),dd(:));
ii = ceil(ii/7);
out = accumarray(ii(lo),P(lo),[],@(x){[mean(x),max(x)]});

댓글 수: 6

Andrei Bobrov
Andrei Bobrov 2015년 7월 14일
편집: Andrei Bobrov 2015년 7월 14일
what is it: v = datevec(timeprac1,P(:,1)); Please see help-doc about datevec.
Please attach your timeprac1 and P.
Andrei Bobrov
Andrei Bobrov 2015년 7월 14일
corrected
Andrei Bobrov
Andrei Bobrov 2015년 7월 15일
Asis! datenum - function of MATLAB. Please rename your script C:\Users\datenum.m
Andrei Bobrov
Andrei Bobrov 2015년 7월 15일
See third variant
Aswas
Aswas 2015년 7월 15일
Works, thank you very much.
Aswas
Aswas 2015년 7월 17일
Hi Andrei,
And how can I get only first years max and mean please, not every year?

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

태그

질문:

2015년 7월 14일

편집:

2015년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by