decimal to hexadecimal with fixed point
    7 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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 件のコメント
回答 (1 件)
  Jessica Clayton
    
 2020 年 12 月 2 日
        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 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Data Type Conversion についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

