Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Number of changes in a value
Date: Wed, 10 Dec 2008 15:44:04 +0000 (UTC)
Organization: Univ of Glasgow
Lines: 13
Message-ID: <ghoo44$e2f$1@fred.mathworks.com>
References: <ghmadq$egh$1@fred.mathworks.com> <ghmcfe$gq8$1@fred.mathworks.com> <y9z%k.777$Ir1.624@newsfe05.iad> <ghmg7g$ic6$1@fred.mathworks.com> <gho5le$9s2$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1228923844 14415 172.30.248.37 (10 Dec 2008 15:44:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 10 Dec 2008 15:44:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1320421
Xref: news.mathworks.com comp.soft-sys.matlab:506112




> Indeed, sparse is the way to go:
> 
> V = [1 2 3 2 4 1 4 2 3 1 4 2 3 2 1 3 2 4 3 2 3 4 2 3 4 1 2 1 2 1] ;
> A = full(sparse(V(1:end-1),V(2:end),1))
> 
> so that A(i,j) holds the number of changes from i to j
> 
> Jos
> 
> 
 Thank you, Sparse is probably the easyest way to do it. What are the diagonal elements?