フィルターのクリア

How do I read commas as decimal points when reading a text file?

9 ビュー (過去 30 日間)
Sam G.
Sam G. 2011 年 4 月 7 日
コメント済み: Michael Haas 2016 年 12 月 8 日
I have a file that I'm trying to read with numerical values that use commas as decimal points. For example...
0 21,875000 120,700000 0,000000
instead of...
0 21.875000 120.700000 0.000000
I've used textscan to read and parse lines in other files.
line = fgetl(fid);
data = textscan(line,'%d %n %n %n',1,'delimiter','\n');
Can I get Matlab to recognize the commas as decimal points?

採用された回答

Paulo Silva
Paulo Silva 2011 年 4 月 7 日
after reading the file replace the decimal points by commas
data=strrep(data,'.',',')
  1 件のコメント
Michael Haas
Michael Haas 2016 年 12 月 8 日
little mistake: data=strrep(data,',','.') is correct

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by