0
$\begingroup$

removing elements from an array that have difference of 3 or less between the next element... eg. A=[3 6 10 14 17 20] to this B=[3 10 14 20]...I believe I can use diff but in what context should I use it to achieve this ?

$\endgroup$
  • 2
    $\begingroup$ That's a general Matlab programming question, not a signal processing question, and is thus off-topic here. $\endgroup$ – Marcus Müller Nov 23 '16 at 14:48
2
$\begingroup$

This code removes all elements that have diff 3 or less to the previous element.

in = [3 6 10 14 17 20 24 25 30 34 38]
in1 = in(2:end);
D = diff(in)
out = [in(1) in1(D > 3)]

output:

in =

     3     6    10    14    17    20    24    25    30    34    38


D =

     3     4     4     3     3     4     1     5     4     4


out =

     3    10    14    24    30    34    38
| improve this answer | |
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.