Convert comma-separated decimal to point-separated decimal

21 Ansichten (letzte 30 Tage)
Darlington Mensah
Darlington Mensah am 29 Jun. 2017
Kommentiert: Matilda Jacobson am 19 Apr. 2022
I have a table with 500 rows and 8 columns. The decimal separation is comma (,). However I would like to convert the separation to point(.)
Is it possible to do this without having to loop through the entire table?
Is there any function that permits conversion (something similar to strrep) when working with tables?
  6 Kommentare
Egor Gurov
Egor Gurov am 11 Sep. 2021
Table.VarName = str2double(regexprep(Table.VarName,',','.'));
It works on Matlab 2020b
Matilda Jacobson
Matilda Jacobson am 19 Apr. 2022
Thank you Egor, it really helped me and my bachelor project!!

Melden Sie sich an, um zu kommentieren.

Antworten (2)

dpb
dpb am 29 Jun. 2017
t.Var=str2double(strrep(t.Var,',','.');
for affected each variable 'Var' in table 't'.
Can generalize into loop or use whatever is most convenient addressing depending on structure of the table, just ensure the form used returns the variable content of the column not another table. See the
doc table % section on addressing for details

Walter Roberson
Walter Roberson am 29 Jun. 2017
TheTable{:, ColumnNumber} = str2double( regexprep(TheTable{:,ColumnNumber}, ',', '.') );

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by