Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
File output, change decimal delimiter vom dot to comma

Subject: File output, change decimal delimiter vom dot to comma

From: Martin Bretschneider

Date: 26 Mar, 2008 08:50:47

Message: 1 of 6

Hi,

I want to write scalars to a ascii file and use fprintf for that purpose.

In Germany, we habe the comma as decimal delimiter, thus 1/2 = 0,5 and
not 0.5. I want to write this to the file. What is the fastest method? I
know that I could to a string-search-and-replace-method but this is not
elegant.

Do you have some hints for me?

Thanks Martin

Subject: File output, change decimal delimiter vom dot to comma

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 27 Mar, 2008 20:36:19

Message: 2 of 6

In article <47ea0e6e$0$4863$9b4e6d93@newsspool4.arcor-online.net>,
Martin Bretschneider <spam@bretschneidernet.de> wrote:

>I want to write scalars to a ascii file and use fprintf for that purpose.

>In Germany, we habe the comma as decimal delimiter, thus 1/2 = 0,5 and
>not 0.5. I want to write this to the file. What is the fastest method? I
>know that I could to a string-search-and-replace-method but this is not
>elegant.

I do not know if Matlab provides any direct method to change the
decimal delimiter; I suspect if they did then someone from Mathworks
would have said so already.

What you can do is sprintf to a string, and then use

string(string == '.') = ',';

and then write the resulting string out.
--
Current spam load: 750-800 messages per day (March 4, 2008)

Subject: File output, change decimal delimiter vom dot to comma

From: Ashish Uthama

Date: 27 Mar, 2008 20:39:56

Message: 3 of 6

Have you tried changing your locale settings?
  Windows' Control Panel -> Regional Options
(making a general assumptions you are on windows)



On Wed, 26 Mar 2008 04:50:47 -0400, Martin Bretschneider =

<spam@bretschneidernet.de> wrote:

> Hi,
>
> I want to write scalars to a ascii file and use fprintf for that purpo=
se.
>
> In Germany, we habe the comma as decimal delimiter, thus 1/2 =3D 0,5 a=
nd =

> not 0.5. I want to write this to the file. What is the fastest method?=
 I =

> know that I could to a string-search-and-replace-method but this is no=
t =

> elegant.
>
> Do you have some hints for me?
>
> Thanks Martin
>

Subject: File output, change decimal delimiter vom dot to comma

From: Martin Bretschneider

Date: 31 Mar, 2008 06:54:43

Message: 4 of 6

Ashish Uthama schrieb:
> Have you tried changing your locale settings?
> Windows' Control Panel -> Regional Options

These have the default parameters. MATLAB does not seem to care about these.

> (making a general assumptions you are on windows)

In this case yes, but I prefer Linux ;)

Subject: File output, change decimal delimiter vom dot to comma

From: muzaffar

Date: 31 Mar, 2008 08:32:02

Message: 5 of 6

 I am afraid that i am not replying to your question but
may be to your problem.
I had similar problem with my data taken from a interface
program (written in German lang).
 i used UltraEdit-32 (and editor similar to notepad but
fast)
http://www.ultraedit.com/downloads/ultraedit_download.html
where you can find option to selection , and then replace
to '.' in just one click it is very fast.
bye
 

Martin Bretschneider <spam@bretschneidernet.de> wrote in
message <47ea0e6e$0$4863$9b4e6d93@newsspool4.arcor-
online.net>...
> Hi,
>
> I want to write scalars to a ascii file and use fprintf
for that purpose.
>
> In Germany, we habe the comma as decimal delimiter, thus
1/2 = 0,5 and
> not 0.5. I want to write this to the file. What is the
fastest method? I
> know that I could to a string-search-and-replace-method
but this is not
> elegant.
>
> Do you have some hints for me?
>
> Thanks Martin
>

Subject: File output, change decimal delimiter vom dot to comma

From: Pekka

Date: 31 Mar, 2008 08:48:01

Message: 6 of 6

Martin Bretschneider <spam@bretschneidernet.de> wrote in
message <47ea0e6e$0$4863$9b4e6d93@newsspool4.arcor-
online.net>...
> Hi,
>
> I want to write scalars to a ascii file and use fprintf
for that purpose.
>
> In Germany, we habe the comma as decimal delimiter, thus
1/2 = 0,5 and
> not 0.5. I want to write this to the file. What is the
fastest method? I
> know that I could to a string-search-and-replace-method
but this is not
> elegant.
>
> Do you have some hints for me?
>
> Thanks Martin

I would just fprintf the commas and replace afterwards. I
posted a function replacinfile to file exchange.
Maybe not elegant but fast with even large files. Way
faster and easier than editors, no mouse clicks required...
 [s, msg] = replaceinfile(',','.', 'Mydatafile.txt');

http://www.mathworks.com/matlabcentral/fileexchange/
loadFile.do?objectId=18909&objectType=file

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us