Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newspeer2.se.telia.net!se.telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail
From: PB <pbodin@_REMOVE_THiS_kth.se>
Subject: Re: Create a new vector from a current vector
Newsgroups: comp.soft-sys.matlab
References: <fgnbec$21u$1@fred.mathworks.com>
User-Agent: Pan/0.129 (Benson & Hedges Moscow Gold)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 25
Message-ID: <hoLXi.13034$ZA.8653@newsb.telia.net>
Date: Mon, 05 Nov 2007 20:52:29 GMT
NNTP-Posting-Host: 217.208.84.46
X-Complaints-To: abuse@telia.com
X-Trace: newsb.telia.net 1194295949 217.208.84.46 (Mon, 05 Nov 2007 21:52:29 CET)
NNTP-Posting-Date: Mon, 05 Nov 2007 21:52:29 CET
Organization: Telia Internet
Xref: news.mathworks.com comp.soft-sys.matlab:436170



Den Mon, 05 Nov 2007 15:04:45 +0000 skrev Amir Safari:

> 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

Another solution

b=filter([1 1 1 1],1,A);
b=b(4:4:end)

/PB