Problem using str2num/str2double
古いコメントを表示
I made a matlab using str2num. When increased the load, str2num was not working. I changed str2num to str2double. I got NaN istead of getting any number. Please send me your email-id if u want me to send the .m file. But, I can't post online.
1 件のコメント
Walter Roberson
2015 年 9 月 12 日
Please clarify what you mean by "increased the load"?
If you disp() the string that you are trying to convert, what does it show up as?
回答 (1 件)
Tim Jackman
2015 年 9 月 15 日
Without seeing the string you are trying to convert, there is not much advice I can give other than to check the string and see if you have any weird characters. For example, the presence of an underscore will cause problems similar to what you describe:
>> test = '3_5';
>> str2num(test)
ans =
[]
>> str2double(test)
ans =
NaN
5 件のコメント
Shivani Rani
2015 年 9 月 16 日
編集済み: Shivani Rani
2015 年 9 月 16 日
Walter Roberson
2015 年 9 月 16 日
What does "load" mean in this context? Is it the number of rows in the file? Is it the number of lines in the file? Is it the size() of a cell array of strings?
When you say that it is not working, what do you see when you try with the higher "load" ?
Shivani Rani
2015 年 9 月 22 日
Walter Roberson
2015 年 9 月 22 日
Time to learn how to use the debugger.
Give the command
dbstop if error
and run your program. When it halts with this error, ask
disp([[Lineelem1 Lineelem2])
size(str2num([Lineelem1 Lineelem2]))
size( Lineelem(j2-6,:) )
Shivani Rani
2015 年 9 月 24 日
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!