How do I convert a cell array with string, double, and NaN values to a double array
4 次查看(过去 30 天)
显示 更早的评论
I have a cell with these values = {1, 2, 'None', 1, 2, 3, 5, NaN, 'None'}
I want to convert this into a double with these values = {1, 2, NaN, 1, 2, 3, 5, NaN, NaN}
Is this possible?
0 个评论
采纳的回答
jonas
2018-9-5
编辑:jonas
2018-9-5
My original solution was obviously flawed, so credits to Guillaume for cleaning up redundant functions
A(strcmp(A, 'None')) = {NaN};
cell2mat(A)
A(~cellfun(@isnumeric,A)) = {NaN}
3 个评论
jonas
2018-9-5
Thanks guys! I put your solutions in the answer box for future reference, as the answer had already been accepted.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!