How to create the Hex format of the address below in MATLAB?
2 次查看(过去 30 天)
显示 更早的评论
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;
0 个评论
回答(1 个)
dpb
2016-5-5
编辑:dpb
2016-5-6
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...
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!