Brian Borchers
2004-05-02 04:52:08 UTC
I have a file containing the line:
C05380394201332C
This is the hexadecimal representation of a particular IEEE double
precision number that was output from another program. I would like to
get this number into MATLAB. The program that produced this number
could also have output it in decimal, but when the first program outputs
a number in decimal using the C format "%.20e", and I then read it in to
MATLAB, I don't get precisely the same value.
I presume that this is because the C runtime library isn't doing the
conversion (on output) to decimal properly, although I suppose that
the problem could also be in MATLAB's conversion on the input.
In any case, the most robust solution would seem to be using the
hexadecimal representation.
I've got the first program producing output in hex without any trouble.
However, I can't seem to figure out a way to get MATLAB to read it in.
I've thought that perhaps '%x' might do the right thing, but it doesn't
seem to work.
As you can probably guess, my actual problem involves rather large
output files with many (millions in some cases) of numbers. Thus
I'd also prefer the quickest possible solution to this.
I've considered using MATLAB's binary format, but since these output
files are used primarily by programs other than MATLAB, that really
isn't appropriate.
--
Brian Borchers ***@nmt.edu
Department of Mathematics http://www.nmt.edu/~borchers/
New Mexico Tech Phone: 505-835-5813
Socorro, NM 87801 FAX: 505-835-5366
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
C05380394201332C
This is the hexadecimal representation of a particular IEEE double
precision number that was output from another program. I would like to
get this number into MATLAB. The program that produced this number
could also have output it in decimal, but when the first program outputs
a number in decimal using the C format "%.20e", and I then read it in to
MATLAB, I don't get precisely the same value.
I presume that this is because the C runtime library isn't doing the
conversion (on output) to decimal properly, although I suppose that
the problem could also be in MATLAB's conversion on the input.
In any case, the most robust solution would seem to be using the
hexadecimal representation.
I've got the first program producing output in hex without any trouble.
However, I can't seem to figure out a way to get MATLAB to read it in.
I've thought that perhaps '%x' might do the right thing, but it doesn't
seem to work.
As you can probably guess, my actual problem involves rather large
output files with many (millions in some cases) of numbers. Thus
I'd also prefer the quickest possible solution to this.
I've considered using MATLAB's binary format, but since these output
files are used primarily by programs other than MATLAB, that really
isn't appropriate.
--
Brian Borchers ***@nmt.edu
Department of Mathematics http://www.nmt.edu/~borchers/
New Mexico Tech Phone: 505-835-5813
Socorro, NM 87801 FAX: 505-835-5366
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----