MATLAB: Extracting near constant elements from an array

constant valuesextractMATLABnearstructure

I have a vector 'data(1).IAS' , which looks like as follows.
data(1).IAS
ans =
288
294
296
294
.
. % length(data(1).IAS) = 153.
I am trying to extract the near constant elements from a vector as shown in the figure (The figure is IAS plotted against its index number).
The problem is that my data.IAS has 693 arrays and it is not possible to do it one by one. Does anyone have any idea how to extract the only near constant parts?
Thanks.
UPDATE: Code
data = load('SSR_20140103.mat'); % Variable name is 'data' with various fields.
newData = data.data;
for i = 1: length(data.data)
x = data.data(i).IAS;
h = [1 1 1 1 1 1 1 1 1 1];
if(length(x)>1)
x1 = [ones(length(h),1)*x(1);x];
x2 = filter(h,1,x1)/length(h);
x2 = x2(length(h):length(x2)-1);
diffx2 = diff(x2);
diffx2 = [ones(length(h),1)*diffx2(1);diffx2];
meandiffx2 = filter(h,1,diffx2)/length(h);
meandiffx2 = abs(meandiffx2(length(h):length(meandiffx2)));
constantIndex = find(meandiffx2<0.25);
constantData.index = constantIndex;
constantData.data = x(constantIndex);
constantValues(i) = {constantData};
newData(i).time = data.data(i).time(constantIndex);
newData(i).lat = data.data(i).lat(constantIndex);
newData(i).lng = data.data(i).lng(constantIndex);
newData(i).altitude = data.data(i).altitude(constantIndex);
newData(i).selected_altitude = data.data(i).selected_altitude(constantIndex);
newData(i).BPS = data.data(i).BPS(constantIndex);
newData(i).RA = data.data(i).RA(constantIndex);
newData(i).TTA = data.data(i).TTA(constantIndex);
newData(i).GS = data.data(i).GS(constantIndex);
newData(i).TAR = data.data(i).TAR(constantIndex);
newData(i).TAS = data.data(i).TAS(constantIndex);
newData(i).heading = data.data(i).heading(constantIndex);
newData(i).IAS = data.data(i).IAS(constantIndex);
newData(i).Mach = data.data(i).Mach(constantIndex);
newData(i).BAR = data.data(i).BAR(constantIndex);
newData(i).IVV = data.data(i).IVV(constantIndex);
end
end

Best Answer

Your airplane appears to be a jet flying a STAR. When it enters Class C airspace, it is told to slow to 250 kts, then is cleared for the approach and flies the approach at 130 kts.
I didn’t run the code, however it seems to be two 10-element moving average filters to create first ‘x2’ and then ‘meandiffx2’. It then thresholds ‘meandiffx2’ and returns the indices of those values that are <0.25 to ‘constantIndex’. (If it doesn’t find any, the find function will return an empty value. This usually throws an error when concatenated with an existing vector, and will obviously not function as an index in the next line, so I don’t know how the code handles this when it does the ‘constantData.index’ and constantData.data assignments.) It then stores the associated values in the designated structures.
This is a powerful argument for documenting code with comments.