Delete NAN + following x values

I have a matrix containing instrument data. Every, lets say, 20 minutes it has a baseline, recorded as NAN followed by some "flushing" values (not useful data). Is there a way I can program Matlab to do something like "find the first NAN of a sequence and delete the next 70 rows? Thank you so much in advance.

回答 (1 件)

KSSV
KSSV 2017 年 2 月 1 日
編集済み: KSSV 2017 年 2 月 1 日

0 投票

A = rand(10,3) ; % some random data
A(7,:) = NaN ; % introduce NaN
idx = find(isnan(A)) ; % find the positions of NaN's
% first row where Nan occurs
row1 = idx(1) ;
% remove the rows
A(row1:end,:) = []

2 件のコメント

Julia Perim de Faria
Julia Perim de Faria 2017 年 2 月 1 日
Thanks! This works for the first occurrence of the NAN. How can I make it a loop, so it deletes all the occurrence (for example I have a daily file with baseline occurrence every 20 minutes or so).
KSSV
KSSV 2017 年 2 月 1 日
編集済み: KSSV 2017 年 2 月 1 日
The number of rows you want to delete after NaN are always fixed?

サインインしてコメントする。

カテゴリ

質問済み:

2017 年 2 月 1 日

編集済み:

2017 年 2 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by