Path: news.mathworks.com!not-for-mail
From: "AP Pal" <avispal@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Data Bin
Date: Mon, 5 Oct 2009 16:49:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <had81v$f9l$1@fred.mathworks.com>
References: <haafq5$mvs$1@fred.mathworks.com>
Reply-To: "AP Pal" <avispal@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1254761343 15669 172.30.248.38 (5 Oct 2009 16:49:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Oct 2009 16:49:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2020759
Xref: news.mathworks.com comp.soft-sys.matlab:575066


Any fast way to reshape the whole matrix?
i mean converting from 100X 50
to                               10X  50

by averaging the 10  rows at a time to bin

the reshape funtion worked for n X 1 matrix only.

"AP Pal" <avispal@gmail.com> wrote in message <haafq5$mvs$1@fred.mathworks.com>...
> I am new to matlab and am stuck  with what seems simple task
> i have  a column of data 1000 pts long. i need to average in groups of 10 so i need to generate a new matrix which has 100pts.
> 
> i was trying to write a code with a mini file and keep making mistakes
> 
> p=X
> n=1;
> i=1;
> m=length(X);
> 
> avg_pts= 2;
> z= length(X)/avg_pts
> % q=0;
> p(1,1)=X(1,1);
> 
>   for i=(1:1:z);
>      
>        for q=(1:1:avg_pts);
>            if n+q<=m
>        p(q,1)=p(q,1)+X(n+q,1);
>            else
>            end
>        end
>        y(i,1)=p(q,1)/avg_pts;
>       n=n+avg_pts;
>       
>   end
>  
> 
> Any help will be greatly appreciated
> thanks