str2num() not working on bigger arrays?
4 次查看(过去 30 天)
显示 更早的评论
Hello, I tried the following, and it is not working:
>> whos Name Size Bytes Class Attributes
XYZasCHARarray 121704x24 5841792 char
>> conversionstep1=str2num(XYZasCHARarray)
conversionstep1 =
[]
>> whos Name Size Bytes Class Attributes
XYZasCHARarray 121704x24 5841792 char
conversionstep1 0x0 0 double
>>
If I proceed on a smaller array (74208x24 char) for testing of my code, this step works fine and produces me the resulting array (74208x3 double) correctly. I so far have no reason to assume that the syntax inside my big char array would be different from the syntax in the smaller char array. Both arrays are the output of my parser, and this parser so far worked without problems, and the input data comes from a huge public scientific database wherein all datafiles should be correctly formated. In a text editor also the big input files looks o.k. . But I finally cannot confirm the big char variable in MATLAB to indeed be o.k. , because the Workspace Variable Browser does not allow to see the content of that array, because it is so big.
Is there a limitation in the use of the str2num() function, or is it a bug? What can I do to get my data converted? Thanks for help!
0 个评论
回答(2 个)
Walter Roberson
2014-2-2
You should be considering using str2double() instead of str2num(). str2num() requires that the strings be executed as commands.
Note: str2double() works on a char vector or a cell array of strings, but not on a char array.
str2double(cellstr(XYZasCHARarray))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!