Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Data Bin
Date: Mon, 5 Oct 2009 20:01:20 +0000 (UTC)
Organization: Universit&#228;t Heidelberg
Lines: 17
Message-ID: <hadjaf$pn1$1@fred.mathworks.com>
References: <haafq5$mvs$1@fred.mathworks.com> <had81v$f9l$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1254772880 26337 172.30.248.38 (5 Oct 2009 20:01:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Oct 2009 20:01:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869888
Xref: news.mathworks.com comp.soft-sys.matlab:575105


Dear AP Pal!

> 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.

No, RESHAPE works really fast for any array, not just for [n x 1] matrices!

The mentioned solution is efficient. A little bit faster, because it avoids the overhead of calling the function MEAN:
  X = rand(100, 50);
  Y = sum(reshape(X, 10, 10, 50), 1) / 10;

Kind regards, Jan