Thread Subject: simple question about number of decimal places

Subject: simple question about number of decimal places

From: David Migl

Date: 28 May, 2008 03:46:01

Message: 1 of 6

Hi,

I am trying to create a matrix; here is my input and output.

[[0:4:28];[69:-1:62];[1.4:-.3:-.7]]
ans =
         0 4.0000 8.0000 12.0000 16.0000 20.0000
  24.0000 28.0000
   69.0000 68.0000 67.0000 66.0000 65.0000 64.0000
  63.0000 62.0000
    1.4000 1.1000 0.8000 0.5000 0.2000 -0.1000
  -0.4000 -0.7000

Is there a way to get the matrix without all the extraneous
zeros following the numbers?

Thanks!!

Subject: simple question about number of decimal places

From: John D'Errico

Date: 28 May, 2008 04:02:04

Message: 2 of 6

"David Migl" <migl.spam@gmail.com> wrote in message
<g1ikhp$8ka$1@fred.mathworks.com>...
> Hi,
>
> I am trying to create a matrix; here is my input and output.
>
> [[0:4:28];[69:-1:62];[1.4:-.3:-.7]]
> ans =
> 0 4.0000 8.0000 12.0000 16.0000 20.0000
> 24.0000 28.0000
> 69.0000 68.0000 67.0000 66.0000 65.0000 64.0000
> 63.0000 62.0000
> 1.4000 1.1000 0.8000 0.5000 0.2000 -0.1000
> -0.4000 -0.7000
>
> Is there a way to get the matrix without all the extraneous
> zeros following the numbers?
>
> Thanks!!

Did you try

format short g

HTH,
John

Subject: simple question about number of decimal places

From: Ravinesh Deo

Date: 30 May, 2008 05:22:01

Message: 3 of 6

Hi John,

I also have same problem.

format g doesn't seem to work. I have some numbers like

A = 0.32075, and I only need the first two decimal. i.e. A =
0.32.

any ideas?



"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g1ilfs$i9m$1@fred.mathworks.com>...
> "David Migl" <migl.spam@gmail.com> wrote in message
> <g1ikhp$8ka$1@fred.mathworks.com>...
> > Hi,
> >
> > I am trying to create a matrix; here is my input and output.
> >
> > [[0:4:28];[69:-1:62];[1.4:-.3:-.7]]
> > ans =
> > 0 4.0000 8.0000 12.0000 16.0000 20.0000
> > 24.0000 28.0000
> > 69.0000 68.0000 67.0000 66.0000 65.0000 64.0000
> > 63.0000 62.0000
> > 1.4000 1.1000 0.8000 0.5000 0.2000 -0.1000
> > -0.4000 -0.7000
> >
> > Is there a way to get the matrix without all the extraneous
> > zeros following the numbers?
> >
> > Thanks!!
>
> Did you try
>
> format short g
>
> HTH,
> John

Subject: simple question about number of decimal places

From: Ravinesh Deo

Date: 30 May, 2008 05:22:01

Message: 4 of 6

Hi John,

I also have same problem.

format g doesn't seem to work. I have some numbers like

A = 0.32075, and I only need the first two decimal. i.e. A =
0.32.

any ideas?



"John D'Errico" <woodchips@rochester.rr.com> wrote in
message <g1ilfs$i9m$1@fred.mathworks.com>...
> "David Migl" <migl.spam@gmail.com> wrote in message
> <g1ikhp$8ka$1@fred.mathworks.com>...
> > Hi,
> >
> > I am trying to create a matrix; here is my input and output.
> >
> > [[0:4:28];[69:-1:62];[1.4:-.3:-.7]]
> > ans =
> > 0 4.0000 8.0000 12.0000 16.0000 20.0000
> > 24.0000 28.0000
> > 69.0000 68.0000 67.0000 66.0000 65.0000 64.0000
> > 63.0000 62.0000
> > 1.4000 1.1000 0.8000 0.5000 0.2000 -0.1000
> > -0.4000 -0.7000
> >
> > Is there a way to get the matrix without all the extraneous
> > zeros following the numbers?
> >
> > Thanks!!
>
> Did you try
>
> format short g
>
> HTH,
> John

Subject: simple question about number of decimal places

From: Ashwini Deshpande

Date: 30 May, 2008 06:48:02

Message: 5 of 6

"Ravinesh Deo" <r.deo1@uq.edu.au> wrote in message
<g1o2tp$ajd$1@fred.mathworks.com>...
> Hi John,
>
> I also have same problem.
>
> format g doesn't seem to work. I have some numbers like
>
> A = 0.32075, and I only need the first two decimal. i.e. A =
> 0.32.
>
> any ideas?
>
>
>
> "John D'Errico" <woodchips@rochester.rr.com> wrote in
> message <g1ilfs$i9m$1@fred.mathworks.com>...
> > "David Migl" <migl.spam@gmail.com> wrote in message
> > <g1ikhp$8ka$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I am trying to create a matrix; here is my input and
output.
> > >
> > > [[0:4:28];[69:-1:62];[1.4:-.3:-.7]]
> > > ans =
> > > 0 4.0000 8.0000 12.0000 16.0000
20.0000
> > > 24.0000 28.0000
> > > 69.0000 68.0000 67.0000 66.0000 65.0000
64.0000
> > > 63.0000 62.0000
> > > 1.4000 1.1000 0.8000 0.5000 0.2000
-0.1000
> > > -0.4000 -0.7000
> > >
> > > Is there a way to get the matrix without all the
extraneous
> > > zeros following the numbers?
> > >
> > > Thanks!!
> >
> > Did you try
> >
> > format short g
> >
> > HTH,
> > John
>

Hi,
@Ravinesh Deo,

Try, format bank

Regards,
Ashwini
 

Subject: simple question about number of decimal places

From: David Migl

Date: 30 May, 2008 15:37:01

Message: 6 of 6

"format short g" took care of it. Thanks all for your help!!

Tags for this Thread

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.

rssFeed for this Thread

Contact us at files@mathworks.com