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)

 채택된 답변

Jan
Jan 2011년 9월 27일

2 개 추천

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.

댓글 수: 9

Aurelien Queffurust
Aurelien Queffurust 2011년 9월 27일
Not only German but also a French feature ;)
Jan
Jan 2011년 9월 27일
편집: Walter Roberson 2019년 3월 23일
@Aurelien: In deed? After a short web research I found out, that my opinion about the freaky Germans is wrong, see http://en.wikipedia.org/wiki/Decimal_mark .
Comma users: Albania, Andorra, Argentina, Armenia, Austria, Azerbaijan, Belarus, Belgium, Bolivia, Bosnia and Herzegovina, Brazil, Bulgaria, Cameroon, Canada (French-speaking), Chile, Colombia, Costa Rica, Croatia (comma used officially, but both forms are in use elsewhere), Cuba, Cyprus, Czech Republic, Denmark, Dominican Republic, Ecuador, Estonia, Faroes, Finland, France, Germany, Greece, Greenland, Honduras, Hungary, Iceland, Indonesia, Italy, Kazakhstan, Latvia, Lebanon, Lithuania, Luxembourg (uses both marks officially), Macau (in Portuguese text), Macedonia, Moldova, Mongolia, Morocco, Netherlands, Norway, Panama, Paraguay, Peru, Poland, Portugal, Romania, Russia, Serbia, Slovakia, Slovenia, South Africa (officially[14]), Spain, Sweden, Tunisia, Turkey, Ukraine, Uruguay, Venezuela, Vietnam.
Aurelien Queffurust
Aurelien Queffurust 2011년 9월 27일
lol
Antonio Napoli
Antonio Napoli 2017년 3월 22일
Italian too
Jan
Jan 2017년 3월 22일
@Antonio: Of course, "Italy" is contained in the list of countries already.
Enri
Enri 2019년 3월 22일
" importing data from Excel to MATLAB can be substantially irritating."
  1. Amen
  2. Exporting data from Matlab to Excel is irritating as well.
Boris Povazay
Boris Povazay 2023년 7월 17일
Well - the decimal comma is no German feature, but the decimal point is an US-of-American one...
and as we all know the US suffers from its own imperialistic weigth, not being able to accept that the world has moved on - forward towards a metric international system. ;-)
Stephen23
Stephen23 2023년 7월 18일
" importing data from Excel to MATLAB can be substantially irritating... Exporting data from Matlab to Excel is irritating as well."
Out of personal curiousity, would you care to explain specifically why?
Walter Roberson
Walter Roberson 2023년 7월 18일
IMHO, MATLAB could make it easier to control cell format and insertion of macros in .xls* files.
And perhaps even make it easier to cram multiple distinct tables inside the same worksheet, since some people prefer to build spreadsheets more for presentation purposes than for machine processing.
My own work has never needed to insert an excel macro, and has seldom needed to change the format for a column or area. The times I have wanted to change the format for a column, it has (as best I can recall) had to do with wanting to change a time representation format.

댓글을 달려면 로그인하십시오.

추가 답변 (6개)

Patrick
Patrick 2011년 9월 27일

0 개 추천

Thanks anyway, i fear Jan Simon is right ;-( poor old Europe

댓글 수: 1

Boris Povazay
Boris Povazay 2023년 7월 17일
Well, the opposite is true ... poor old imperial system and stubborn USA. 🤔

댓글을 달려면 로그인하십시오.

Daniel Gregorius
Daniel Gregorius 2018년 5월 3일
편집: Daniel Gregorius 2018년 5월 3일

0 개 추천

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

Stephen23
Stephen23 2019년 3월 23일
x = str2double(strrep(get(handles.point,'String'),',','.'))
Or in a more general case:
x = str2double(strrep(str,',','.'))
Govind Narayan Sahu
Govind Narayan Sahu 2022년 6월 19일
This works perfectly fine for me. Short and simple.
Thanks a lot.

댓글을 달려면 로그인하십시오.

Johannes Kalliauer
Johannes Kalliauer 2020년 11월 30일

0 개 추천

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]);

카테고리

제품

질문:

2011년 9월 27일

댓글:

2023년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by