From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Data Manipulation (Re-arranging) and Writing to text file
Date: Mon, 18 Jun 2012 10:24:25 -0500
Organization: NNTP Server
Lines: 36
Message-ID: <jrnh7c$33j$>
References: <jrm6nb$787$> <jrmb7j$5iu$> <jrnf37$nlk$>
NNTP-Posting-Host: q9ROquIwoNmofcJt/
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20120306 Thunderbird/3.1.20
X-Notice: Filtered by postfilter v. 0.8.2
Xref: comp.soft-sys.matlab:771480

On 6/18/2012 9:48 AM, Stan wrote:
>> x(:,2:end)=[]; % retain column only 1 for simplicity in addressing
> ..
> ..
> ..
>> x=reshape(x,6,length(x)/6)'; % now you've got rows of length 6
> Is it possible to extract a subset of a matrix, where you indicate the
> range of matrix elements to be extracted? I mean, after aplying the
> second command (reshaping which gave rows of length 6), could the first
> 11 rows be extracted by specifying (not the row numbers, but) the range
> of matrix elements to be extracted - in this case [1:66]?

Of course, but the linear address of the first 66 isn't the same as the 
first 11 rows as Matlab storage order is column-major.

But, all you need is to write out


for whatever value of M you need and then the one or two or however many 
that aren't full as

x(M+N,1:2)  % for N = 1, 2, ... , whatever it is you want

If there are more remaining of the same pattern then put this in a loop 
and increment by M+N for the first row index.  If the pattern changes, 
then you'll need to add the logic to compute the M and N as you iterate 
through as well, but if you know what it is, then that should be no 
problem even if you have to do it as a lookup table because it's irregular.

NB, of course, that owing to the column major storage order you'll need 
to use the ' (transpose) operator on the submatrices to write them in 
rows as displayed on the screen to the file...