matlab - How should I write a matrix onto a text in Hex format? -


i have matrix, say:

m = [1000 1350;2000 2040;3000 1400]; 

i wish write matrix onto text file in hex format, this:

0x000003e8 0x00000bb8   0x000007d0 0x000007f8    0x00000bb8 0x00000578   

i considered using function dec2hex it's slow , inefficient. gives me output string, don't know how restructure above required format.

matlab directly converts hex numbers decimal when reading text file, ex. when using function fscanf(fid,'%x').

can exact same thing while writing matrix?

you can use %x format string. sake of demonstration, see example sprintf below. if want write file, have use fprintf.

m = [1000 1350;2000 2040;3000 1400]; str = sprintf('0x%08x\t0x%08x\n', m') 

this results in

str =  0x000003e8  0x00000546 0x000007d0  0x000007f8 0x00000bb8  0x00000578 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -