Thread Subject: fprintf - get rid of exponential -

Subject: fprintf - get rid of exponential -

From: recep mansiz

Date: 11 Jun, 2009 07:48:01

Message: 1 of 7

Hi all!!

I'm writing some numbers into a file. I want to write them without any dots(.) or exponentials(e) but I can't.

i.e. I use the command

 fprintf (truefile,'%8d\n',true);

to write the number '80539' to file. but in file I see '8.053900e+004'.

how can I get rid of these (.) and (e)?

Thanks in advance...

Subject: fprintf - get rid of exponential -

From: Sprinceana

Date: 11 Jun, 2009 07:56:01

Message: 2 of 7

"recep mansiz" <aalmoraa@hotmail.com> wrote in message <h0qcrh$rfn$1@fred.mathworks.com>...
> Hi all!!
>
> I'm writing some numbers into a file. I want to write them without any dots(.) or exponentials(e) but I can't.
>
> i.e. I use the command
>
> fprintf (truefile,'%8d\n',true);
>
> to write the number '80539' to file. but in file I see '8.053900e+004'.
>
> how can I get rid of these (.) and (e)?
>
> Thanks in advance...

Hi!

>>help format

That should do the trick. Change the format of numbers.

Hope this helps you !

Best regards,

Michael

Subject: fprintf - get rid of exponential -

From: recep mansiz

Date: 11 Jun, 2009 08:18:01

Message: 3 of 7

thanks for your reply Michael.

I read each line of 'format' and 'fprintf' help pages but I couldn't find a solution to my problem.

do you think that there is an alternative way??

Subject: fprintf - get rid of exponential -

From: Sprinceana

Date: 11 Jun, 2009 08:30:20

Message: 4 of 7

"recep mansiz" <aalmoraa@hotmail.com> wrote in message <h0qejp$d3t$1@fred.mathworks.com>...
> thanks for your reply Michael.
>
> I read each line of 'format' and 'fprintf' help pages but I couldn't find a solution to my problem.
>
> do you think that there is an alternative way??

As far as I know you should use format short to have 5 decimals so type in command window :

>>format short

Then I'm not sure if I'm saying right you should eliminate the decimals for your number using a dedicated function in matlab:

Here's the link:

http://www.lmgtfy.com/?q=remove+decimals+from+number+matlab+function

If you're done please tell me how you remove the decimals from a number I don't have matlab at my means to test this!

Thanks and waiting for your reply!


Just an idea!

Mike

Subject: fprintf - get rid of exponential -

From: Sprinceana

Date: 11 Jun, 2009 08:45:03

Message: 5 of 7

So you want to round a number:

In this case you can use:

>>a=31.19453

>>rounded_result = roundn(31.19453,-1)
>>roundeed_result

Subject: fprintf - get rid of exponential -

From: recep mansiz

Date: 11 Jun, 2009 09:42:02

Message: 6 of 7

"Sprinceana " <mihaispr@yahoo.com> wrote in message <h0qg6f$7rv$1@fred.mathworks.com>...
> So you want to round a number:
>
> In this case you can use:
>
> >>a=31.19453
>
> >>rounded_result = roundn(31.19453,-1)
> >>roundeed_result

and this is the answer. thanks for your help Michael.

Subject: fprintf - get rid of exponential -

From: Sprinceana

Date: 11 Jun, 2009 10:32:01

Message: 7 of 7

With pleasure!

Also look to this thread:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/253410

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
scientific numb... Sprinceana 11 Jun, 2009 06:34:05
remove decimals... Sprinceana 11 Jun, 2009 04:34:04
format function... Sprinceana 11 Jun, 2009 03:59:22
fprintf recep mansiz 11 Jun, 2009 03:49:02
rssFeed for this Thread

Contact us at files@mathworks.com