use comma as decimal seperator

307 views (last 30 days)
Patrick
Patrick on 27 Sep 2011
Hi,
i have a simple question and this is my last try, as i've been searching the web all morning:
Is there a way to use comma as decimal seperator instead of a period/dot in matlab?
Even maybe only in figures/axis format?
Thanks, any help is gratefully appreciated!
ps: i set the reagional settings in Windows/MacOS (using both) to German (--> Comma)

Accepted Answer

Jan
Jan on 27 Sep 2011
The answer is easy: no.
Using the comma is a German feature. In the world of scientific computing the dot is always used as decimal separator. Only Excel is affected by this setting, and in consequence importing data from Excel to MATLAB can be substantially irritating.
  6 Comments
Enri
Enri on 22 Mar 2019
" importing data from Excel to MATLAB can be substantially irritating."
  1. Amen
  2. Exporting data from Matlab to Excel is irritating as well.

Sign in to comment.

More Answers (6)

Daniel Shub
Daniel Shub on 27 Sep 2011
You might want to check out this link:

TAB
TAB on 27 Sep 2011

Patrick
Patrick on 27 Sep 2011
Thanks anyway, i fear Jan Simon is right ;-( poor old Europe

Adam
Adam on 1 Dec 2012

Daniel Gregorius
Daniel Gregorius on 3 May 2018
Edited: Daniel Gregorius on 3 May 2018
Hey. When dealing with this problem, this is what I came up with. It's an extract of a GUI. People kept entering values with comma (,) instead of a point (.) and then it didn't work so I thought of the following code, that seems to work. I am still not sure if I have thought of everything and this is probably alot more complicated than it should be. Hopefully this still helps. It basically converts input with comma as decimal seperator into a value seperated by decimal point.
x=str2num(get(handles.point,'String'));%get point - everything alright if the delimiter is a .
if size(x,2)>1 %it's not a . but a ,
strx=get(handles.point,'String'); %need to check for sign
splitstrx=strsplit(a1,','); %try to extract length of 2nd string, divide x(2) by 10^strlength
if strx(1)=='-'
x=x(1)-x(2)/10^strlength(splitstrx(1,2)); %it's negative, need to substract 2nd string
else
x=x(1)+x(2)/10^strlength(splitstrx(1,2)); %it's positive
end
end
  2 Comments
Govind Narayan Sahu
Govind Narayan Sahu on 19 Jun 2022
This works perfectly fine for me. Short and simple.
Thanks a lot.

Sign in to comment.


Johannes Kalliauer
Johannes Kalliauer on 30 Nov 2020
For Matrixes to CSV I recommend on linux/Mac-machines (On Windows you have to install sed)
writematrix(MyMatrix,filename,'Delimiter',';')
system(['exec sed -i "s/\./,/g" ',filename]);

Community Treasure Hunt

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

Start Hunting!

Translated by