use comma as decimal seperator
    109 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
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)
0 Commenti
Risposta accettata
  Jan
      
      
 il 27 Set 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.
9 Commenti
  Stephen23
      
      
 il 18 Lug 2023
				" 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
      
      
 il 18 Lug 2023
				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.
Più risposte (6)
  Patrick
      
 il 27 Set 2011
        1 Commento
  Boris Povazay
 il 17 Lug 2023
				Well, the opposite is true ... poor old imperial system and stubborn USA.  🤔
  Adam
 il 1 Dic 2012
        Look there (just for function plots): http://frommyplayground.com/2012/12/decimal-comma-in-matlab-plots/
0 Commenti
  Daniel Gregorius
 il 3 Mag 2018
        
      Modificato: Daniel Gregorius
 il 3 Mag 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 Commenti
  Stephen23
      
      
 il 23 Mar 2019
				x = str2double(strrep(get(handles.point,'String'),',','.'))
Or in a more general case:
x = str2double(strrep(str,',','.'))
  Johannes Kalliauer
 il 30 Nov 2020
        writematrix(MyMatrix,filename,'Delimiter',';')
system(['exec sed -i "s/\./,/g" ',filename]);
0 Commenti
Vedere anche
Categorie
				Scopri di più su Text Files in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!