I need to display a data

1 vue (au cours des 30 derniers jours)
Aswas
Aswas le 14 Juil 2015
Modifié(e) : Aswas le 18 Juil 2015
Can someone assist please:
  1 commentaire
Azzi Abdelmalek
Azzi Abdelmalek le 14 Juil 2015
Modifié(e) : Azzi Abdelmalek le 14 Juil 2015
Do you mean for the first week of each month or of what? can you give more details about your first column?

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 14 Juil 2015
Modifié(e) : Andrei Bobrov le 15 Juil 2015
% 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 commentaires
Aswas
Aswas le 15 Juil 2015
Works, thank you very much.
Aswas
Aswas le 17 Juil 2015
Hi Andrei,
And how can I get only first years max and mean please, not every year?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by