Converting Strings in a Cell Array to Doubles (trickier than you think)
이전 댓글 표시
Hello,
I have a very large cell array full of strings. Most of these cells contain strings that are really doubles in string format. Some are just pure strings. Some cells are also strings that are combinations of strings and doubles in string format. There are also some cells that are empty.
I would like to convert this cell array into another cell array that is exactly the same, except all the cells that were purely doubles in string format are now doubles NOT in string format.
I have one solution, which is: Data_Out= cellfun(@(x)str2double(x), Data_In);
However, this solution is very time taxing. I would prefer a more simple solution.
I've also tried playing around with the "isstrprop" function but have not found a solution using this yet.
Any help would be greatly appreciated.
댓글 수: 1
Jan
2017년 5월 26일
An explicite example of the cell would be useful. How do you want to treat "1e4", "Inf" and "NaN"? How is a "pure string" or "pure number" identified reliably?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!