use comma as decimal seperator
显示 更早的评论
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)
采纳的回答
更多回答(6 个)
Daniel Shub
2011-9-27
0 个投票
You might want to check out this link:
TAB
2011-9-27
0 个投票
May be this can help you
Patrick
2011-9-27
0 个投票
1 个评论
Boris Povazay
2023-7-17
Well, the opposite is true ... poor old imperial system and stubborn USA. 🤔
Adam
2012-12-1
0 个投票
Look there (just for function plots): http://frommyplayground.com/2012/12/decimal-comma-in-matlab-plots/
Daniel Gregorius
2018-5-3
编辑:Daniel Gregorius
2018-5-3
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
2019-3-23
x = str2double(strrep(get(handles.point,'String'),',','.'))
Or in a more general case:
x = str2double(strrep(str,',','.'))
Govind Narayan Sahu
2022-6-19
This works perfectly fine for me. Short and simple.
Thanks a lot.
Johannes Kalliauer
2020-11-30
writematrix(MyMatrix,filename,'Delimiter',';')
system(['exec sed -i "s/\./,/g" ',filename]);
类别
在 帮助中心 和 File Exchange 中查找有关 Environment and Settings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!