How transform all ‘NaN’ string in double NaN for each rows
3 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I have this table:
Date A B C D
'03-Jan-2005' 'NaN' 583 'NaN' 217
'04-Jan-2005' 872 586 'NaN' 219
'05-Jan-2005' 873 578 'NaN' 221
'06-Jan-2005' 888 572 'NaN' 222
'07-Jan-2005' 881 'NaN' 'NaN' 223
'10-Jan-2005' 879 564 'NaN' 222
My question is:
how to transform all 'NaN' value that I find in my table rows in a numeric(double) format?
Thank you very much for your answers.
0 个评论
回答(2 个)
Ameer Hamza
2020-9-10
Try str2num() for this case: https://www.mathworks.com/help/releases/R2020a/matlab/ref/str2num.html
T.C = str2num(T.C);
2 个评论
Ameer Hamza
2020-9-10
Can you attach the actual table in a .mat file? In your question, Column A and B contain 'NaN' and double values. However, such mixing of data types is not possible in Matlab (unless it is a column of cells). Attaching the file will be helpful in this case.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!