Path: news.mathworks.com!not-for-mail
From: "edward kabanyas" <djuky_hmi@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: insert new value to matrix
Date: Tue, 15 May 2012 09:36:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 54
Message-ID: <jot826$889$1@newscl01ah.mathworks.com>
Reply-To: "edward kabanyas" <djuky_hmi@yahoo.com>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1337074566 8457 172.30.248.38 (15 May 2012 09:36:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 15 May 2012 09:36:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1278033
Xref: news.mathworks.com comp.soft-sys.matlab:767892

Dear all;

Suppose we have a matrix A as:

A = 
[1	11	1	8	100	100
1	11	1	8	100	100
1	11	1	9	100	100
1	11	1	9	100	100
1	11	1	12	100	100
1	11	1	12	100	100
1	11	1	13	100	100
1	11	1	13	100	100];

3th and 4th column are day and hour, respectively. The data from the same hour are repeated every 2 rows . I want to make hour/time in sequence, for which no sequence I want to add new data such as 0. From the above case, it becomes:

Anew =
[1	11	1	8	100	100
1	11	1	8	100	100
1	11	1	9	100	100
1	11	1	9	100	100
1	11	1	10	0	0
1	11	1	10	0	0
1	11	1	11	0	0
1	11	1	11	0	0
1	11	1	12	100	100
1	11	1	12	100	100
1	11	1	13	100	100
1	11	1	13	100	100];

Another example

A=
[1	11	1	23	100	100
1	11	1	23	100	100
1	11	2	1	100	100
1	11	2	1	100	100];

This must be:
Anew=
[1	11	1	23	100	100
1	11	1	23	100	100
1	11	2	0	0	0
1	11	2	0	0	0
1	11	2	1	100	100
1	11	2	1	100	100]

For now, I am thinking to use looping procedure, by checking every 3 rows of 3th and 4th column. Probably you have another option/suggestion. Thanks for sharing..

Best regards,

Edward