Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!d2g2000pra.googlegroups.com!not-for-mail
From: Nathan <ngreco32@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Reshaping Dataset
Date: Thu, 25 Jun 2009 14:22:57 -0700 (PDT)
Organization: http://groups.google.com
Lines: 61
Message-ID: <7b8a043f-ce0a-4684-b96a-a8ca5c331e83@d2g2000pra.googlegroups.com>
References: <h20j9k$9ok$1@fred.mathworks.com> <h20o76$864$1@fred.mathworks.com> 
	<h20p1e$1nf$1@fred.mathworks.com>
NNTP-Posting-Host: 198.206.219.33
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1245964979 4548 127.0.0.1 (25 Jun 2009 21:22:59 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 25 Jun 2009 21:22:59 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: d2g2000pra.googlegroups.com; posting-host=198.206.219.33; 
	posting-account=_KeVcAoAAAB7j3xn35ujaQ0BoQhuzwJP
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) 
	Gecko/2009060215 Firefox/3.0.11,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 wwwproxy-son-ca-01.ca.sandia.gov:80 (squid/2.5.STABLE14)
Xref: news.mathworks.com comp.soft-sys.matlab:550737


On Jun 25, 2:09 pm, "Jeremy Bing" <jer...@mytrashmail.com> wrote:
> "Jos " <#10...@fileexchange.com> wrote in message <h20o76$86...@fred.mathworks.com>...
> > "Jeremy Bing" <jer...@mytrashmail.com> wrote in message <h20j9k$9o...@fred.mathworks.com>...
> > > Hi,
>
> > > I have data in the form of the following.
>
> > > X Y Z X Y Z  >>
> > > X Y Z X Y Z
> > > X Y Z X Y Z
> > > X Y Z X Y Z
> > > ...
>
> > > But i need the data to be:
>
> > > X Y Z
> > > X Y Z
> > > X Y Z
>
> > > Do i used a case statement or a nested forloop to reshape the data? The dataset is quite large.
>
> > If I understand this correctly, you need column 4-6 to appear below column 1-3?
>
> > B = [A(:,1:3) ; A(:,4:6)] ;
>
> > hth
> > Jos
>
> Hi,
>
> I need column(4,1:3) put underneath 1:3. i used this method:
>
> r2 = numel(r(:,1));
>
> for iii = 1:r2
> kdkrm(1:21,1:3) = [r(iii,1:3);r(iii,4:6);r(iii,7:9);r(iii,10:12);r(iii,13:15);r(iii,16:18);r(iii,19:21);r(iii,22:24);r(iii,25:27);r(iii,28:30);r(iii,31:33);r(iii,34:36);r(iii,37:39);r(iii,40:42);r(iii,43:45);r(iii,46:48);r(iii,49:51);r(iii,52:54);r(iii,55:57);r(iii,58:60);r(iii,61:63)];
> end
>
> but it is quite long and this only deals with the first row. all other rows under also need to go through this so i think i need a nested forloop.
>
> Thanks
>
> Jeremy

How about...
B = [];
for ii = 1:length(A(:,1))
for jj=1:(length(A)/3)
B = [B;A(1,3*(jj-1)+1:3*(jj-1)+3)];
end
end

-Nathan