Hi everyone,
If I have a matrix of the form
x=[44 378 45 46 47 379 48 390 391 392 52 53 54 400 401];
I want to reduce the matrixsch that no set of adjacent elements are consecutive in which case only the first number is considered i.e, the resulting output is
y=[44 378 45 379 48 390 52 400];
Pls help. Thanx in advance.
|
|
0
|
|
|
|
Reply
|
astro
|
3/29/2010 2:33:08 PM |
|
"astro mmi" <pyarsa_madhu@yahoo.co.in> wrote in message <hoqdn4$4bq$1@fred.mathworks.com>...
> Hi everyone,
> If I have a matrix of the form
> x=[44 378 45 46 47 379 48 390 391 392 52 53 54 400 401];
> I want to reduce the matrixsch that no set of adjacent elements are consecutive in which case only the first number is considered i.e, the resulting output is
> y=[44 378 45 379 48 390 52 400];
> Pls help. Thanx in advance.
one of the many solutions
v=[44 378 45 46 47 379 48 390 391 392 52 53 54 400 401];
r=v([true,diff(v)~=1])
% r = 44 378 45 379 48 390 52 400
us
|
|
0
|
|
|
|
Reply
|
us
|
3/29/2010 2:55:21 PM
|
|