Create new column based on whether values in another column are NaN or a number

2 ビュー (過去 30 日間)
Thomas Lees
Thomas Lees 2022 年 6 月 13 日
コメント済み: Thomas Lees 2022 年 6 月 13 日
I have a data set with multiple variables, formatted as a timetable. The timetable is currently 20101 x 616.
The variable of interest ('Event_Z') records the occurence of something that I am interested in. The remaining variables are recorded at intervals of one minute. For minutes where an Event_Z occurred, an interger is recorded; for minutes where no Event_Z occurred, NaN is recorded.
I would like to create a new variable in my dataset ('Event_Z_Yes') with a true/false condition, such that :
  • For minutes where an Event_Z value is present, the value is converted to a '1'
  • For minutes where an Event_Z is not present, the NaN value is converted to a '0'.
How would I do this?

採用された回答

dpb
dpb 2022 年 6 月 13 日
tData.Event_Z_Yes=isfinite(tData.Event_Z);
  1 件のコメント
Thomas Lees
Thomas Lees 2022 年 6 月 13 日
Smashing. Thanks very much!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by