print hexadecimal representation of 16 bit word

조회 수: 52 (최근 30일)
Anthony
Anthony 2025년 11월 10일 12:45
댓글: dpb 2025년 11월 10일 17:46
I keep messing it up
I've got a 16 bit word that's supposed to be the hexadecimal representation of a number.
How do I print that hexadecimal representation?

답변 (1개)

dpb
dpb 2025년 11월 10일 14:40
Somewhat dependent upon the context, but some options include
V=65535;
fprintf('%s\n',dec2hex(V)) % convert to internal string
FFFF
fprintf('%X\n',V) % use builtin format conversion
FFFF
If this doesn't resolve whatever issues you're having, show us the context of the problem and what you're trying to do, specifically.
  댓글 수: 4
Anthony
Anthony 2025년 11월 10일 16:55
Thanks for the help, you've been great. I'll have to get with the engineers and see how they want to handle it.
dpb
dpb 2025년 11월 10일 17:46
The alternative would be to store =DEC2HEX(value) in the cell of interest(*), but you might be forced to actually write to Excel directly for it to recognize and interpret/evaluate the formula on opening a .csv file; I've not ever tried that. I write formulas all the time, but use writecell with the 'UseExcel',1 parameter.
(*) But, that also converts that cell to text so to calculate with it, formulas referencing the cell will have to do the conversion back as well just as if stored the explicit text representation.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by