Replace comma with dot after fopen
Show older comments
Hello everyone,
I am having some problems with Matlab.
I import a txt file with fopen and, after imported, I want to convert the commas in the file with dots but I do not know how to do. I have searched between the answers in the Matlab Central but I have found nothing.
Thank you for the help.
4 Comments
KSSV
on 19 Oct 2021
Read about strrep.
Stephen23
on 19 Oct 2021
"I have searched between the answers in the Matlab Central but I have found nothing"
Here are 339 results, many of which are related to file importing:
Daniele Sonaglioni
on 19 Oct 2021
Daniele Sonaglioni
on 19 Oct 2021
Accepted Answer
More Answers (1)
fnm = 'trial_file.txt';
opt = detectImportOptions(fnm, 'VariableNamesLine',9, 'VariableUnitsLine',10, 'DecimalSeparator',',', 'ExtraColumnsRule','ignore');
opt.DataLines = [11,Inf];
tbl = readtable(fnm, opt)
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!