can we write hexadecimal values in matlab too?
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Imtiaz nabi
il 4 Mar 2022
Commentato: Walter Roberson
il 5 Mar 2022
Hi there I want to write some hexadecimal values in matlab for example
// Add TOW-count message into HOW
if (iwrd==1)
sbfwrd |= ((tow&0x1FFFFUL)<<13);
// Compute checksum
sbfwrd |= (prevwrd<<30) & 0xC0000000UL; // 2 LSBs of the previous transmitted word
nib = ((iwrd==1)||(iwrd==9))?1:0; // Non-information bearing bits for word 2 and 10
chan->dwrd[iwrd] = computeChecksum(sbfwrd, nib);
0 Commenti
Risposta accettata
Walter Roberson
il 4 Mar 2022
0x1FFFFu32
The C code is a bit weak in that it assumes unsigned long is 32 bits.
4 Commenti
Walter Roberson
il 5 Mar 2022
Starting in R2019b, you can write hexadecimal and binary values as literals using an appropriate prefix as notation. For example, 0x2A is a literal that specifies 42—and MATLAB stores it as a number, not as text.
So the reason for the difference between the r2019b system and your R2017b system is that MATLAB was improved as of R2019b to support hexadecimal constants.
Which is why earlier I said "in your version" of MATLAB that hex2dec and sscanf were your available choices.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!