Thread Subject: Format Data Type

Subject: Format Data Type

From: juliette Salexa

Date: 19 Dec, 2008 20:15:06

Message: 1 of 5

When I apply the command: format short , my numbers only arrive as 5 digit strings.

When I apply the command:format long, my numbers arrive as massive 14 digit strings.

I want to be able to customize this. Ideally I should be able to do something like:

short=8 , and then: format short, would make my numbers have 8 digits instead of 5.

Is there a way to do this in matlab?

Subject: Format Data Type

From: someone

Date: 19 Dec, 2008 20:28:02

Message: 2 of 5

"juliette Salexa" <n_dattani@hotmail.com> wrote in message <gigvca$j7d$1@fred.mathworks.com>...
> When I apply the command: format short , my numbers only arrive as 5 digit strings.
>
> When I apply the command:format long, my numbers arrive as massive 14 digit strings.
>
> I want to be able to customize this. Ideally I should be able to do something like:
>
> short=8 , and then: format short, would make my numbers have 8 digits instead of 5.
>
> Is there a way to do this in matlab?

doc sprintf

Subject: Format Data Type

From: juliette Salexa

Date: 19 Dec, 2008 22:46:02

Message: 3 of 5

That response did NOT help me!!

"someone" <someone@somewhere.net> wrote in message <gih04i$7k1$1@fred.mathworks.com>...
> "juliette Salexa" <n_dattani@hotmail.com> wrote in message <gigvca$j7d$1@fred.mathworks.com>...
> > When I apply the command: format short , my numbers only arrive as 5 digit strings.
> >
> > When I apply the command:format long, my numbers arrive as massive 14 digit strings.
> >
> > I want to be able to customize this. Ideally I should be able to do something like:
> >
> > short=8 , and then: format short, would make my numbers have 8 digits instead of 5.
> >
> > Is there a way to do this in matlab?
>
> doc sprintf

Subject: Format Data Type

From: Walter Roberson

Date: 19 Dec, 2008 23:07:08

Message: 4 of 5

juliette Salexa wrote:
> When I apply the command: format short , my numbers only arrive as 5 digit strings.

> When I apply the command:format long, my numbers arrive as massive 14 digit strings.
 
> I want to be able to customize this. Ideally I should be able to do something like:

> short=8 , and then: format short, would make my numbers have 8 digits instead of 5.

> Is there a way to do this in matlab?


No, there is no way to do that in Matlab, as the premise is incorrect. The 'format'
command affects only the display of values via disp() or by default output
(no semi-colon after an expression), and in no way affects the number of digits
that "arrive", and in no way affects the number of digits that are saved in .mat
files or that are saved via save -ascii, and in no way affects csvwrite() or
dlmwrite().

If your request is to change the format used by disp() or by default output,
to something not already supported by the 'format' command, then NO, there is
no way to do that.


> That response did NOT help me!!

That response did not help -us- to know what was not acceptable about using sprintf()
in your situation.

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Subject: Format Data Type

From: Doug Schwarz

Date: 20 Dec, 2008 03:04:31

Message: 5 of 5

In article <lOV2l.59509$yB4.51551@newsfe07.iad>,
 Walter Roberson <roberson@hushmail.com> wrote:

> If your request is to change the format used by disp() or by default output,
> to something not already supported by the 'format' command, then NO, there is
> no way to do that.

Well, that's not quite true -- you can overload disp and display to do
whatever you want.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

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
sprintf someone 19 Dec, 2008 15:30:08
rssFeed for this Thread

Contact us at files@mathworks.com