I'm not totally sure I understand the question, but this is how I am interpreting it. You have an array of data, and would like to determine which entries, when compared with any of the subsequent three entries, will have an absolute difference in value of 15 or greater.
If you were just checking the entries against their subsequent value, this would largely be trivial using the diff function:
rng default
v = randi([-20 20], 10, 1);
dv = diff(v);
whichVals = abs(dv) >= 15;
whichVals = [whichVals ; false];
v(whichVals)
find(whichVals)
Now, you could probably come up with something fancy using convolution or something similar to deal with all three subsequent values at once. But since you are checking a known and small number of subsequent values, it might be easier to just check each of them individually. You can use some basic indexing to check the second value after the value in question, though you have to check evens and odds separately:
evenIdx = 2:2:numel(v);
oddIdx = 1:2:numel(v);
dvEven = diff(v(evenIdx));
dvOdd = diff(v(oddIdx));
whichVals(evenIdx) = whichVals(evenIdx) | [abs(dvEven) >= 15 ; false];
whichVals(oddIdx) = whichVals(evenIdx) | [abs(dvOdd) >= 15 ; false];
The OR with the previous values of whichVals is done because the value still counts if it were found to have a valid difference with the next index, not the one after that.
You can do something similar for the values separated by three from the entry of interest.
-Cam