How can I make data points in one variable NaN according to another time-based variable?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
balsip
am 28 Okt. 2015
Beantwortet: Star Strider
am 28 Okt. 2015
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.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 28 Okt. 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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!