フィルターのクリア

Deleting 'NaN' rows out of a table

2 ビュー (過去 30 日間)
jrbbrt
jrbbrt 2018 年 7 月 13 日
コメント済み: Peter Perkins 2018 年 8 月 3 日
Hi everybody!
I got: A table (18316x4). Within the last two columns I got strings representing time (saved in cells). So sometimes instead of a date, here I can find a string called "NaN".
I'd like to: Remove those "NaN" rows I can find in my 3rd column, so later on I can transform my string-dates into real datetimes.
What I got so far: Only the idea of using the function "isnan" (though here I get the error message, that it is undefined for input arguments of type cell OR that I got too many input arguments)or the function "find" ... Which doesn't work either.
nan1=t(all(isnan(t.r(:,1)),3),:);
nan2=find(t.r{:,1});
My question: How can I easily remove the "NaN"-Strings out of my table, or better say, the whole row where I can find one?
I appreciate all help I get! Best regards.

採用された回答

Walter Roberson
Walter Roberson 2018 年 7 月 13 日
編集済み: Walter Roberson 2018 年 7 月 13 日
Convert to datetime first. The nan will become NaT. Then use https://www.mathworks.com/help/matlab/ref/rmmissing.html
  3 件のコメント
Paolo
Paolo 2018 年 7 月 13 日
If the data contains milliseconds like for your previous question, you forgot to include the sss specified in datetime.
Use:
date = datetime(t.r(:,1),'InputFormat','dd.MM.yyyy HH:mm:ss.SSS')
Peter Perkins
Peter Perkins 2018 年 8 月 3 日
It's likely that t.r(:,1) isn't what you expect it to be. What is it? Perhaps you can show t.r(1:5,1).

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by