How to convert a number in to hexa decimal in Simulink without using functions?
    17 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Raja Vardhan Reddy Kothakapu
 am 21 Feb. 2020
  
    
    
    
    
    Kommentiert: Walter Roberson
      
      
 am 24 Feb. 2020
            Hi everyone,
I am trying to convert a number in to hexa decimal in Simulink without using any functions. Is there any way that this can be done with existing Simulink block? or else can anyone suggest me what would be the best way to do it in Simulink?
Thanks in Advance
1 Kommentar
  Walter Roberson
      
      
 am 24 Feb. 2020
				Integer or floating-point numbers? Signed or unsigned? Range of values?
There are techniques that are workable (if slightly tedious) for integers 0 to 255 that get more tiresome as you increase the range.
Heck, for small integers I would probably just use a pair of lookup tables.
Akzeptierte Antwort
  Samatha Aleti
    
 am 24 Feb. 2020
        Hi, 
You may use  "MATLAB function block" in your SIMULINK model to convert a number into hexadecimal format using “dec2hex" function. 
Refer the sample SIMULINK model attached. 
6 Kommentare
  Walter Roberson
      
      
 am 24 Feb. 2020
				Use two math blocks. The first one is uint8(floor(double(x)/16)) . The second is uint8(mod(x, 16)) . You can do the same thing for each of the 8 bytes, and put the resulting signals into a block that puts them together into a vector of whatever order you want.
Math blocks can be optimized inline by the Simulink accelerator so this can be efficient.
If you have a vector of 8 bytes already then extracting the nibbles can be done in vectorized form. Then it just becomes a matter of splicing the two vectors together, which can be done by concatenation and reshape.
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Event Functions 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!


