フィルターのクリア

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

1 回表示 (過去 30 日間)
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.

採用された回答

Star Strider
Star Strider 2015 年 10 月 28 日
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 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by