How to get NaN if the data is not in proper input format or missing?

1 回表示 (過去 30 日間)
Atanu
Atanu 2022 年 5 月 31 日
コメント済み: Atanu 2022 年 6 月 1 日
I am running a function over each table rows. It is a big table and some of the entries are 'NaN' (class: 'double') or 'none' (class: 'char'). There may some missing entries too. I want to get 'NaN' as output if any of the table entries is not a valid entry. How should I approach it? I have uploaded the table in attachment. My function is as follows.
function [logical_out, reaction_time, average_position] = new_table2(name,date,Trial)
  3 件のコメント
Atanu
Atanu 2022 年 6 月 1 日
Thank you. Let me try.
Atanu
Atanu 2022 年 6 月 1 日
You are right. All the NaN entries for 'playstarttrialtone' and 'presentcost' gave me NaN as output without doing anything.
By the way, I have converted all the columns from cellstring to double (e.g., playstarttrialtone and presentcost) or string ('subjectid') as I thought would be appropriate. But the bad entries in the subjectid column is specified as 'none' in the table. So they are still giving me outputs.

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

採用された回答

Walter Roberson
Walter Roberson 2022 年 5 月 31 日
編集済み: Walter Roberson 2022 年 5 月 31 日
https://www.mathworks.com/help/matlab/ref/standardizemissing.html
standardize missing. Then rmmissing https://www.mathworks.com/help/matlab/ref/rmmissing.html with the second output to show which rows were removed. Run the function on the reduced data, and then inject the results into a larger vector of nan values to match up to the original rows.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by