Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Create a new vector from a current vector
Date: Mon, 5 Nov 2007 15:42:07 +0000 (UTC)
Organization: fz
Lines: 26
Message-ID: <fgndkf$4ma$1@fred.mathworks.com>
References: <fgnbec$21u$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1194277327 4810 172.30.248.35 (5 Nov 2007 15:42:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Nov 2007 15:42:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1088664
Xref: news.mathworks.com comp.soft-sys.matlab:436108



"Amir Safari" <amsa36060@yahoo.com> wrote in message
<fgnbec$21u$1@fred.mathworks.com>...
> 
> Hi MATLAB users,
> 
> Suppose we have a matrix or vector with only one column of 
> length 20.
> 
> A=[1,3,3,4,2,4,3,5,5,2,4,3,7,4,2,4,1,4,2,3];
> 
> My question is that how to create a new matrix or vector 
> from A so that the new vector be sums of every 4 values of 
> A. Therefore the new vector of B will have a length of 5.
> 
> B=[11,14,14,17,10];
> 
> How to create B from A?
> 
> Thank you very much.
> Amir


aa = reshape(A, 4,numel(A)/4);
B = sum(aa)

should do