Path: news.mathworks.com!not-for-mail
From: "jay vaughan" <jvaughan5.nospam@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: combine data?
Date: Wed, 16 Jul 2008 08:37:10 +0000 (UTC)
Organization: harvard
Lines: 37
Message-ID: <g5kbvl$2f4$1@fred.mathworks.com>
References: <g5k9qk$kc5$1@fred.mathworks.com> <2bc34cc4-1c0a-401f-af4a-0c5479ec0e4c@c65g2000hsa.googlegroups.com>
Reply-To: "jay vaughan" <jvaughan5.nospam@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 1216197430 2532 172.30.248.37 (16 Jul 2008 08:37:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 16 Jul 2008 08:37:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1215048
Xref: news.mathworks.com comp.soft-sys.matlab:479691



Hi Maxim,

thanks for the speedy reply. Your code essentially does the 
following...

v1=unique(v);

What I would like to do is to find the sum of those 
elements in w whose corresponding elements in v are the 
same. For example, in v the 2nd and 3rd elements are both 
4, so I summed the 2nd & 3rd elements from w in the output 
to get 1+2=3 in w_summed, etc.

v = [1 4 4 5 6 10 10 10 16]
w = [1 1 2 1 1 4  2  2  1];

v_unique = [1 4 5 6 10 16];
w_summed = [1 3 1 1 8  1];


Any thoughts? Thanks,
J

vedenev <vedenev.maxim@gmail.com> wrote in message 
<2bc34cc4-1c0a-401f-af4a-
0c5479ec0e4c@c65g2000hsa.googlegroups.com>...
> here is the code:
> 
> v=[1 4 4 5 6 10 10 10 16]
> dv=diff(v);
> r=find(dv);
> v1=[v(r) v(end)]
> 
> ------------------------------------
> Maxim Vedenev, Matlab freelancer
> http://simulations.narod.ru/