From: MOOON MOOON on

Ok,

thanks ..

this is well understood, but there is a question that came into my mind

and this problem is the same problem that I have in my research.

I have a matrix containing the power demand for every day in the whole

year, so we have 365 points as follows:

P=[4 3 5 2 3 6 ........3 2 7]

So, the value ( 4 ) is the first value of January, then 3, then 5

and continues for the remaining months until the value ( 7 )

which is the value number 31 of December.

Actually, the example given in previous post was in

systematic matrix and the application was made in sequence to the matrix elements.

But,I want the new matrix P to include the first 20 elements of each

month and ignore the remaining days which are 8 or 9 or 10 or 11 depending

on the month.

AND THIS IS THE PROBLEM. THE NUMBER OF DAYS IS DIFFERENT FOR EACH MONTH

The problem is: the days of the months are different and we cannot

go in systematic way as in the previous examples.

In reality, if all months have equal number of days, we will not

face any problem applying the previous methods.

we have for January:31 days

February: 28 days, March : 31 days and so on

How can we proceed in this matter.

I am sorry for disturb you, but this matter is very urgent for me

since I am currently doing my master degree thesis work.

Thanks
From: ImageAnalyst on
You know what day of the year each month starts on and what day of the
year the 20th of the month is. It's the same every year, with the
exception of leap years but that's easy to handle. So just extract
them, for example

P2 = [P(1:20), P(32:51), and so on];

Is that not right -- am I overlooking something? Seems rather trivial
to me.
From: MOOON MOOON on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <cc3d68a4-cbe5-4fc2-9aaf-857b343a7a5c(a)i10g2000yqh.googlegroups.com>...
> You know what day of the year each month starts on and what day of the
> year the 20th of the month is. It's the same every year, with the
> exception of leap years but that's easy to handle. So just extract
> them, for example
>
> P2 = [P(1:20), P(32:51), and so on];
>
> Is that not right -- am I overlooking something? Seems rather trivial
> to me.


Oh,

execuse me, I do not have a good background about matlab.

Thanks, I understand the matter perfectly

thank you for your help
From: TideMan on
On May 13, 2:37 pm, "MOOON MOOON" <shaheed...(a)yahoo.com> wrote:
> Ok,
>
> thanks ..
>
> this is well understood, but there is a question that came into my mind
>
> and this problem is the same problem that I have in my research.
>
> I have a matrix containing the power demand for every day in the whole
>
> year, so we have 365 points as follows:
>
> P=[4 3 5 2 3 6 ........3 2 7]
>
> So, the value ( 4 ) is the first value of January, then 3, then 5
>
> and continues for the remaining months until the value ( 7 )
>
> which is the value number 31 of December.
>
> Actually, the example given in previous post was in
>
> systematic matrix and the application was made in sequence to the matrix elements.
>
> But,I want the new matrix P to include the first 20 elements of each
>
> month and ignore the remaining days which are 8 or 9 or 10 or 11 depending
>
> on the month.
>
> AND THIS IS THE PROBLEM. THE NUMBER OF DAYS IS DIFFERENT FOR EACH MONTH
>
> The problem is: the days of the months are different and we cannot
>
> go in systematic way as in the previous examples.
>
> In reality, if all months have equal number of days, we will not
>
> face any problem applying the previous methods.
>
> we have for January:31 days
>
> February: 28 days, March : 31 days    and so on
>
> How can we proceed in this matter.
>
> I am sorry for disturb you, but this matter is very urgent for me
>
> since I am currently doing my master degree thesis work.
>
> Thanks

Here's one way:
yr=2010;
t1=datenum(yr,1,1); % 1-Jan-yyyy
t2=datenum(yr+1,1,1)-1; % 31-Dec-yyyy
t=[t1:t2]'; % Days of the year in Matlab days
date=str2num(datestr(t,'yyyymmdd'));
indx=find(mod(date,100) <= 20);

P(indx) are your data.

From: Matt Fig on
Another method:

% Data
D = round(rand(1,365)*6);
N = 20; % Keep this many days of each month.

% Engine
EM = eomday(2010,1:12); % See the help.
S = [1 cumsum(EM(1:11))+1];
E = S + (N-1);
SE = cumsum(E - S + 1);
idx = ones(1,SE(12));
idx(1+SE(1:11)) = S(2:12) - E(1:11);
D2 = D(cumsum(idx)); % The new data set.