decimal to hexadecimal with fixed point
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have the following code: that turns a string hexadecimal value into a numbers like [-0.12 -0.34 0.67 0.54 -0.128 0.256 ...]:
f_aux0 = fi(1,0,8,0);
% Read first value
t_dat0 = fgetl(fid0);
t_dat1 = fgetl(fid1);
% Get data arrays
while (i < l)
f_aux0.hex = t_dat0;
ADC(i) = (f_aux0.data - 2^7)/2^7;
(...)
that turns a string hexadecimal value into a numbers like [-0.12 -0.34 0.67 0.54 -0.128 0.256 ...].
I want to do the inverse, this means, to convert a number like [-0.12 -0.34 0.67(...) in hexadecimal with the same " fi "
I also tried something like this:
adc=adc + (adc<0).*2^7;
hexstring=dec2hex(adc, ceil(7/4));
But gave me an error, in some cases the values were negative...
If some one can help me.
0 Kommentare
Antworten (1)
Jessica Clayton
am 2 Dez. 2020
I understand that you are trying to convert between decimal and hex notation for fixed point values. This answer provides several different methods of accomplishing this task.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!