Borrar filtros
Borrar filtros

How can I make data points in one variable NaN according to another time-based variable?

1 visualización (últimos 30 días)
I have one variable (X) for which I need to remove data (convert to NaN) for a ten-minute time span when another variable (Y) switches.
Some background: (Y) stays constant until it switches from 3 to, say, 4. For a ten-minute period after this process of switching begins, the data is unreliable.
I'm very green at all this, and I don't know how to phrase the time component, but could certainly use guidance with all of it.

Respuesta aceptada

Star Strider
Star Strider el 28 de Oct. de 2015
One possibility:
t = 0:100; % Create Time Vector (Minutes)
X = 2 + sin(0.1*pi*t);; % Create ‘X’
Y = 3*ones(size(t));
Y(17) = 4; % Create ‘Y’
switch_idx = find(Y > 3); % Detect Index OF ‘Y Switch’
X(switch_idx:switch_idx+9) = NaN; % Set ‘X’ To NaN For 10 Minutes
figure(1)
subplot(2,1,1)
plot(t, X)
grid
subplot(2,1,2)
plot(t, Y)
grid
This is simplified by design. You might need additional code to calculate the index range for your 10 minute ‘time out’ depending on your sampling frequency.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by