Re: Subplot frustration
- From: dpb <none@xxxxxxx>
- Date: Thu, 23 Aug 2007 17:42:02 -0500
Paul Mennen wrote:
Actually, while I've not pursued it, on reflection I
suspect that they are floating point numbers is only
an artifice of ML's representation of the internal handle as a default Double...
I've often been curious why they didn't stick to integers
despite the fact that they use a 64 bit double as the
handle. There are many many billions of integers that
can be represented as a 64 bit double, far more handles
than any practical program could ever use. So I don't
see the drawback to sticking with integers.
Occasionally I have found it useful to be able to assign
a unique string to graphic objects. The logical way to do
that would be "s=num2str(h)" where h is the object's handle.
While this does generate a unique string it has the drawback
that you can't use it to get the original handle back. If
you try "h=str2num(s)" you will find that h is not a handle.
That is because of the loss of precision that happens when
converting to decimal representations of floating point numbers.
I have found a trick that gets around this problem.
Use "s = num2str(h*8192)". Then one can get the original
handle back via "h = str2num(s)/8192". The reason this
trick works is that Matlab always uses handles that are
an exact multiple of 1/8192. So when you multiply the
handle by 8192 you get an integer, which can be converted
to a decimal string with no loss of precision. I haven't
seen anywhere that TMW guarantees that this will always
be true, so perhaps someday my programs will break because
of this assumption. However this assumption has so far
proved valid for the first version using handle graphics
and every subsequent release up to and including the
current version.
Interesting observation...I hadn't ever delved into the actual numerics sufficiently to notice the precise limit of precision, but it would obviously be desirable that the last bit of precision not be a problem if they were, indeed, processed somehow internally as floats.
My supposition is that they _are_ fundamentally integers but the storage in fp makes them _appear_ to be fractions. As I say, I've not investigated that thoroughly either but to me at least, it makes sense why that would be so as noted above.
My other supposition is that the "handle graphics" package was a product not developed inside TMW, but that again is an assumption.
--
.
- References:
- Subplot frustration
- From: First Last
- Re: Subplot frustration
- From: dpb
- Re: Subplot frustration
- From: First Last
- Re: Subplot frustration
- From: dpb
- Re: Subplot frustration
- From: First Last
- Re: Subplot frustration
- From: dpb
- Re: Subplot frustration
- From: us
- Re: Subplot frustration
- From: dpb
- Re: Subplot frustration
- From: us
- Re: Subplot frustration
- From: dpb
- Re: Subplot frustration
- From: First Last
- Re: Subplot frustration
- From: dpb
- Re: Subplot frustration
- From: dpb
- Re: Subplot frustration
- From: Paul Mennen
- Subplot frustration
- Prev by Date: Re: Problem using m-file
- Next by Date: Re: Problem using m-file
- Previous by thread: Re: Subplot frustration
- Next by thread: Re: Subplot frustration
- Index(es):
Relevant Pages
|