How to convert 'comma' to 'dot'?
古いコメントを表示
Hi;
I have a txt file. But it includes comma. How can I convert comma to dot? Because with comma I can not obtain the exact graphic..
Thanks a lot.
I attach the txt file.
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2016 年 6 月 10 日
編集済み: Azzi Abdelmalek
2016 年 6 月 10 日
a=importdata('test2.txt')
b=strrep(a,',','.')
c=cell2mat(cellfun(@str2num,b,'un',0))
2 件のコメント
Mohamed Asaad
2022 年 2 月 7 日
Hi! This works for me. However when i use files including negative value or Nan, it does not work. I get error message " Conversion to double from struct is not possible."
The output type of importdata() varies depending on how it manages to split the text based on the specified delimiters. There are probably other ways to do this, but consider this. I've simply renamed the extensions so that they can be uploaded and run here.
A = importdata('Au_1_E_chem_experiment_SPR_angle_offset_after_PEG.txt',' ');
A = strrep(A,',','.'); % convert commas to dots
A = regexp(A,'([^\t]*)','tokens'); % split each line into its elements
B = cellfun(@str2double,vertcat(A{:})); % convert to numeric
B(1:10,:) % show a sample
Similarly for the other file
A = importdata('Au_1_E_chem_experiment_TIR_angle.txt',' ');
A = strrep(A,',','.'); % convert commas to dots
A = regexp(A,'([^\t]*)','tokens'); % split each line into its elements
B = cellfun(@str2double,vertcat(A{:})); % convert to numeric
B = B(2:end,:); % strip off the header
B(55:64,:) % show a sample
カテゴリ
ヘルプ センター および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!