Hello Everyone, I'm trying to replace data in a cell array with NaN based on a range of values of max and min. In other words, if my data is below the minimum or the maximum range, then replace with NaN, if the data is within the range then leave the value as it is. This aims to filter the data. My data is stored in a cell array with time tables and the data is recorded every minute in average (sometimes more than 1 min). On the other hand, the range timetable is recorded every 24 hr.
nrows=size(TGC,1);
FDATA=cell(nrows,1);
A=cell(nrows,1);B=cell(nrows,1);CT1=cell(nrows,1);CT=cell(nrows,1); FDATA=cell(nrows,1);
for h=1:nrows
A=TGC{h,1};
k=size(C{h,1},1);
kk=size(A,1);
AT=datenum(A.Time);
for hh=2:k
CT1=C{h,1}(hh-1,2);
CT=C{h,1}(hh,2);
for hhh=1:kk
ATG=AT(hhh,1);
if or(ATG >= CT1,ATG < CT)
CVar = C{h,1}(hh-1,3);
DVar = D{h,1}(hh-1,3);
AVar = A{hhh,3};
if CVar >= AVar && AVar >= DVar
FDATA{h,1}(hhh,1)=AVar;
else
FDATA{h,1}(hhh,1)=NaN;
end
end
end
end
end
Note: FDATA is the cell array with the filter data. TGC is the raw data with a cell array of size 1x9, and each cell is a timetable with 2xn, data every ~1 min C is a cell array with the maximum values to filter TGC, data every 24 hr D is a cell array with the minimum values to filter TGC, data every 24 hr
The next figure shows the problem with the results from a single cell, as you can see the filter data (Distance) is not following the max and min range over time.
Thanks for any input you might have.