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