Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Number of changes in a value
Date: Tue, 9 Dec 2008 18:13:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 13
Message-ID: <ghmcfe$gq8$1@fred.mathworks.com>
References: <ghmadq$egh$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 1228846382 17224 172.30.248.38 (9 Dec 2008 18:13:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 9 Dec 2008 18:13:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:505900

"anoop Sivasankaran" <anooppgd@gmail.com> wrote in message <ghmadq$egh$1@fred.mathworks.com>...
> An entry-level qestion.
> 
> I have a data file (1 x 5000000), which shows different states of my model during integration. I have four states and i have used 1, 2,3,4 to indicate each state. So the entire data file contain these 4 numbers. 
> 
> Now I need to find number of changes. i.e I need to find how many changes from 1 to 2, 1 to 3, 1 to 4, 2 to 1, 2 to 3 etc. 
> 
> Please let me know how to do this

sum(diff(data)~=0)

Roger Stafford