alan dinno wrote:
> Hi -
>
> If V is a col vector, I want H to be the number of highest
> consecutive sequential count in V.
>
> Example: If V=[22; 23; 24; 40; 44; 50; 51; 52; 53]
> Then, since the highest consecutive count comes from
> numbers 50,51,52 and 53,it means H=4.
>
> Another example:
> If V=[6; 9; 14; 15; 16; 50; 58; 52; 53], then since the
> highest consecutive count comes from 14,15,16, it means
> H=3.
Didn't think about exact implementation but logic would be select values
of diff(V) == 1 as they're the adjacent integer locations (less one).
"alan dinno" <alan_dinno@hotmail.com> wrote in message <fkf1sr$a05
$1@fred.mathworks.com>...
> Hi -
>
> If V is a col vector, I want H to be the number of highest
> consecutive sequential count in V.
>
> Example: If V=[22; 23; 24; 40; 44; 50; 51; 52; 53]
> Then, since the highest consecutive count comes from
> numbers 50,51,52 and 53,it means H=4.
>
> Another example:
> If V=[6; 9; 14; 15; 16; 50; 58; 52; 53], then since the
> highest consecutive count comes from 14,15,16, it means
> H=3.
>
> Thanks
> al
-------
Try this:
"Roger Stafford"
<ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message <fkf5hg$jta$1@fred.mathworks.com>...
> "alan dinno" <alan_dinno@hotmail.com> wrote in message
<fkf1sr$a05
> $1@fred.mathworks.com>...
> > Hi -
> >
> > If V is a col vector, I want H to be the number of
highest
> > consecutive sequential count in V.
> >
> > Example: If V=[22; 23; 24; 40; 44; 50; 51; 52; 53]
> > Then, since the highest consecutive count comes from
> > numbers 50,51,52 and 53,it means H=4.
> >
> > Another example:
> > If V=[6; 9; 14; 15; 16; 50; 58; 52; 53], then since
the
> > highest consecutive count comes from 14,15,16, it
means
> > H=3.
> >
> > Thanks
> > al
> -------
> Try this:
>
> H = max(diff(find([1,diff(V)~=1,1])));
>
> Roger Stafford
>
It gives me the error message:
??? Error using ==> horzcat
All matrices on a row in the bracketed expression must
have the same number of rows.
"alan dinno" <alan_dinno@hotmail.com> wrote in message <fkf60b$an6
$1@fred.mathworks.com>...
> "Roger Stafford"
> <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> > Try this:
> > H = max(diff(find([1,diff(V)~=1,1])));
>
> It gives me the error message:
>
> ??? Error using ==> horzcat
> All matrices on a row in the bracketed expression must
> have the same number of rows.
>
> al
-----------
My apologies. I forgot that your V is a column vector, not a row vector. For
a column vector use:
"Roger Stafford"
<ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message <fkf899$9gu$1@fred.mathworks.com>...
> "alan dinno" <alan_dinno@hotmail.com> wrote in message
<fkf60b$an6
> $1@fred.mathworks.com>...
> > "Roger Stafford"
> > <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> > > Try this:
> > > H = max(diff(find([1,diff(V)~=1,1])));
> >
> > It gives me the error message:
> >
> > ??? Error using ==> horzcat
> > All matrices on a row in the bracketed expression must
> > have the same number of rows.
> >
> > al
> -----------
> My apologies. I forgot that your V is a column
vector, not a row vector. For
> a column vector use:
>
> H = max(diff(find([1;diff(V)~=1;1])));
>
> Roger Stafford
>
>
"alan dinno" <alan_dinno@hotmail.com> wrote in message
<fkf1sr$a05$1@fred.mathworks.com>...
> Hi -
>
> If V is a col vector, I want H to be the number of
highest
> consecutive sequential count in V.
>
> Example: If V=[22; 23; 24; 40; 44; 50; 51; 52; 53]
> Then, since the highest consecutive count comes from
> numbers 50,51,52 and 53,it means H=4.
>
> Another example:
> If V=[6; 9; 14; 15; 16; 50; 58; 52; 53], then since the
> highest consecutive count comes from 14,15,16, it means
> H=3.
>
> Thanks
> al
Hi rojar, this logic gives '1' when their is no sequence of
consicutive number.
"hemant " <swarnkar@mathworks.com> wrote in message <fkfts3$bku
$1@fred.mathworks.com>...
> Hi rojar, this logic gives '1' when their is no sequence of
> consicutive number.
---------
Are you saying that answer is wrong, Hemant? If so, I would disagree. If there
exists a sequence of two consecutive numbers but none longer, the correct
answer would be 2. That is clear. With no consecutive sequences, which is
another way of saying that each element is a single "consecutive sequence", it is
more reasonable in my opinion to give an answer of 1 rather than 0.
The one questionable aspect of this code is that it gives an answer of 1 even if
V is an empty sequence. One could correct that if desired with an appropriate
"if-else" statement.
Roger Stafford
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.