The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Concatenating matrix columns causes loss of precision
Replies: 4   Last Post: Aug 24, 2013 12:03 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Roger Stafford

Posts: 5,929
Registered: 12/7/04
Re: Concatenating matrix columns causes loss of precision
Posted: Aug 24, 2013 12:03 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Rohit" wrote in message <kv6sli$fml$>...
> I want the resulting matrix to have the original precision of temp1. How do I do this?
- - - - - - - - -
It is important to realize that what you see in matlab's display is only a decimal representation of the number actually used by the computer but rounded off to a certain number of significant decimal digits depending on the rounding format. When you display an entire array of numbers of greatly differing sizes, the display generally uses the same number of significant digits for all elements. In your example you were originally displaying the first array to ten digits and the second one to seven. The display of the the concatenated array was to seven which makes it appear as though you have lost the last three digits of the first column, but this is untrue. As James has said, there will be no change in the numbers as stored internally to your machine.

If you want to see the precise numbers as they are stored and used for computations, use "format hex" which represents the exact 64 binary digits that are used to represent a double precision floating point number, or the 32 for a single precision number. These hexadecimal numbers are not easy to interpret, since they are in the IEEE 754 format. To accomplish this see, for example, the pdf file at:

Roger Stafford

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.