Effacer les filtres
Effacer les filtres

How to create the Hex format of the address below in MATLAB?

2 vues (au cours des 30 derniers jours)
Mostafa Darvishi
Mostafa Darvishi le 5 Mai 2016
Modifié(e) : dpb le 6 Mai 2016
Hi everyone,
I have a sequence of addresses like below. Please keep noticed that the sequence of address must be like below: first 4 hex digits then a comma then t hree hex digits
example:
0000,000
0000,001
.
.
.
0000,51F
0001,000
0001,001
.
.
.
0001,51F
.
.
.
.
20C5,000
20C5,001
.
.
.
20C5,51F
As you see the maximum value for 4-hex-digit is 20C5 and the maximum value for 3-hex-digit is 51F while the ',' must separate them. I did a lotf of trials to generate those sequences. Until now I could generate the 4-hex-digit and 3-hex-digit numbers by the following code but the challenge is that how to merge them together as the format explained above?!! Kind helps are in advance appreciated ! Regards,
Code:
FAddr = [0:1:8389]';
Bit = [0:1:1311]';
for i = 0 : 1 : FAddr
FAddr_h = dec2hex(FAddr);
%out_1 = sprintf('%4s,', FAddr_h)
end;
for j = 0 : 1 : Bit
Bit_h = dec2hex(Bit);
end;

Réponses (1)

dpb
dpb le 5 Mai 2016
Modifié(e) : dpb le 6 Mai 2016
FAddrMax = 8389;
BitMax = 1311;
k=0;
for i = 0:FAddrMax
for j = 0:BitMax
k=k+1; % increment output array counter
str{k}=sprintf('%04X,'%03X',i,j); % write cellstring
end
end
ADDENDUM BTW, you recognize this is going to be a long list of 11,019,488 values, I presume? That'll be some 80 MB or so...

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by