Using isnan to check if there is any NaNs in a window and setting all the values to NaN if there are any.
2 views (last 30 days)
Show older comments
Gus Abraham
on 2 Mar 2021
Answered: Walter Roberson
on 2 Mar 2021
I'm trying to use isnan to find if there is any NaNs in y in a window of 12 time points and if there are set all values for X in the window to NaN. but I'm running into some issues.
This is the code I've used
for i=1:11:T;
for k=1:3;
if isnan(y(i:i+11,k));
X(i:i+11,k) =NaN;
end
end
end
The part I believe is the issue is "if isnan(x(i:i+11,k))", because if I use if isnan(x(i,k)) it works but then it only sets X(i:i+11,k) to NaN if the i'th y is NaN (i.e it doesn't check the whole window)
Any ideas of what I could do?
0 Comments
Accepted Answer
Walter Roberson
on 2 Mar 2021
for i=1:11:T;
for k=1:3;
if any(isnan(y(i:i+11,k)))
X(i:i+11,k) =NaN;
end
end
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!