Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Data Manipulation (Re-arranging) and Writing to text file
Date: Thu, 28 Jun 2012 01:37:09 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <jsgcg5$dnr$1@newscl01ah.mathworks.com>
References: <jrm6nb$787$1@newscl01ah.mathworks.com> <jrmb7j$5iu$1@speranza.aioe.org> <jrnf37$nlk$1@newscl01ah.mathworks.com> <jrno98$luu$1@speranza.aioe.org> <jro45e$lh6$1@speranza.aioe.org> <jrrp0t$8a$1@newscl01ah.mathworks.com> <jrsduv$f2d$1@speranza.aioe.org> <jrshf8$oev$1@speranza.aioe.org> <jrvbq3$cqf$1@newscl01ah.mathworks.com> <jrvq6g$qfd$1@speranza.aioe.org> <js1sa4$ir6$1@speranza.aioe.org>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1340847429 14075 172.30.248.47 (28 Jun 2012 01:37:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 28 Jun 2012 01:37:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3536503
Xref: news.mathworks.com comp.soft-sys.matlab:772358

My apologies. I re-read through the original post. As you indicated, there was a mistake with the boundary condition.

The boundary condition is actually 186.i.e. there are exactly 186 elements in the row vector (62 X 3).
So, based on this, I changed that last line to i1 = i2+1. I then went through the loop as you suggested and here is what I have come up with:

Loop1:
i1 = 1, i2 = i1 + 59 = 1 + 59 = 60
fprintf prints elements 1-60 on rows 1 to 10
on the 11th row, it prints 61 and 62
This is the end of loop1

Loop2:
i1 = 63, i2 = 122
fprintf prints elements 63-123 on rows 12 to 21
on the 22nd row, it prints 61 and 62
This is the end of loop2

Loop3:
i1 = 125, i2 = 125 + 59 = 184
fprintf prints elements 125-184 on rows 23 to 32
on the 33rd row, it prints 185 and 186
This is the end of loop3

Loop4:
i1=187 ? this is > length(x) so the loop exits.

fprintf is done printing.

That is it for this vector, x. I would repeat the exact same process for 4 other vectors.

If this makes sense, it would give me the desired output (same as what I displayed above – 3 blocks of 62). Does this seem reasonable or have I mis-accounted for the boundary condition?

Also, regarding (i1+62)<length(x):
This would no longer be needed. Is this correct or is the loop not going to exit correctly?