Path: news.mathworks.com!not-for-mail
From: "AP Pal" <avispal@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Data Bin
Date: Sun, 4 Oct 2009 19:15:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 48
Message-ID: <haas7n$nib$1@fred.mathworks.com>
References: <haafq5$mvs$1@fred.mathworks.com> <haakjv$6r1$1@fred.mathworks.com>
Reply-To: "AP Pal" <avispal@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1254683703 24139 172.30.248.37 (4 Oct 2009 19:15:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 4 Oct 2009 19:15:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2020759
Xref: news.mathworks.com comp.soft-sys.matlab:574863



Thanks a lot Andrew, it really saved me so much headache.

"Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <haakjv$6r1$1@fred.mathworks.com>...
> "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
> 
> Hi,
> 
> You many want to try something like:
> 
> %generate a dataset
> y=rand(1000,1);
> 
> %average in 10 point bins
> ym=mean(reshape(y,10,100));
> 
> -Andrew