How to create the Hex format of the address below in MATLAB?
조회 수: 1 (최근 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!