Using isnan to check if there is any NaNs in a window and setting all the values to NaN if there are any.

2 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Mzo. de 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

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by