フィルターのクリア

what str2num will perform?

1 回表示 (過去 30 日間)
Shan Sha
Shan Sha 2018 年 11 月 13 日
コメント済み: Rik 2018 年 11 月 13 日
fid = fopen(txtfile,'r');
tline = fgetl(fid);
index = findstr(tline,'.');
i = i+1;
filenames(i) = str2num(tline(1:index-1))+1;
what is the function of str2num here? I am not getting clear with the mathwork help. Can anyone explain in brief?
  2 件のコメント
Adam
Adam 2018 年 11 月 13 日
編集済み: Adam 2018 年 11 月 13 日
It converts a string to a number, if such a conversion makes sense.
You can just try it on your command line, e.g.
str2num( '17' )
Surely
doc str2num
is fairly clear though?! It gives clear examples.
Rik
Rik 2018 年 11 月 13 日
As the documentation mentions, str2num uses eval and might thus have unintended side effects, which you can avoid by using str2double. In most cases these two functions should be equivalent.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeString についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by