Complex numbers in matlab
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Name Size Bytes Class Attributes
z 1x1 16 double complex
I know this information about a complex number, but I was wondering how it is stored in the internal memory? How is it written in hexadecimals or in binary code? How can I convert such a code to the number and the way around?
Thanks in advance..
0 Kommentare
Antworten (3)
Walter Roberson
am 6 Dez. 2012
Internally, MATLAB stores complex arrays as a single variable header with two data pointers, one pointing to the real part and the other pointing to the imaginary part. The data blocks store the arrays in order of dimension, the first dimension (row) varying most quickly (everything for one column is in one place), then the second column, then the third, and so on.
Complex numbers can have any non-sparse numeric datatype as their basis. You can have complex uint8() for example. So we cannot speak of just one storage representation for the numeric values.
The default datatype for numbers in MATLAB is "double", which corresponds exactly to IEEE 754 Double Precision. Those are 64 bit numbers with a number of binary subfields: sign, exponent, and mantissa (also called fraction). See here for a more detailed description.
"single precision" ("float") is similar but only 32 bits. There is an example of converting to IEEE Single Precision here and the link at the bottom of that page shows an example of converting back. The principles are the same for Double Precision but the number of bits is different in some parts.
When you do the conversion, watch out for the "hidden bit".
0 Kommentare
Azzi Abdelmalek
am 6 Dez. 2012
I assume That a complex number is stored as two numbers: real part and imaginary part
0 Kommentare
José-Luis
am 6 Dez. 2012
Bearbeitet: José-Luis
am 6 Dez. 2012
To look how numbers are stored in .mat files you could look at the .mat file white paper. To make a long story short, it is a binary file. I don't understand your comment about hexadecimal: if it's in a computer, it's binary; hexadecimal is just a convenient way of visualizing data (as are text files).
That requires some knowledge of C++/Fortran. But if you are proficient in those languages, you could implement your own interface. I would recommend against that unless you are sure of what your are doing as it is really easy to screw things up (and why reinvent the wheel?).
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!