Prev: plotting 3d 'cone'
Next: Speed bottleneck
From: Heman on 19 Jul 2010 20:42 hi frnds, can anyone tell me how to write the decimal data onto a text file in hex format. thanks
From: neil on 19 Jul 2010 20:57 "Heman " <kokahemant(a)hotmail.com> wrote in message <i22rct$q05$1(a)fred.mathworks.com>... > hi frnds, > > can anyone tell me how to write the decimal data onto a text file in hex format. > > thanks Use the dec2hex function to convert to hex then something like fid = fopen('filename.dat','wt') fprintf(fid,'%s',dec2hex(10)); fclose(fid); You might want to play with the formatting of the fprintf command a bit. See the doc on that one
From: Heman on 19 Jul 2010 21:27 "neil " <neil.iain(a)gmail.com> wrote in message <i22s8v$krb$1(a)fred.mathworks.com>... > "Heman " <kokahemant(a)hotmail.com> wrote in message <i22rct$q05$1(a)fred.mathworks.com>... > > hi frnds, > > > > can anyone tell me how to write the decimal data onto a text file in hex format. > > > > thanks > > Use the dec2hex function to convert to hex > then something like > fid = fopen('filename.dat','wt') > fprintf(fid,'%s',dec2hex(10)); > fclose(fid); > > You might want to play with the formatting of the fprintf command a bit. See the doc on that one Hey Neil, i tried the below code. It is writing but i dunno why but the written data is not in hexadecimal format. It is writing in exponential format. fid = fopen ('in_data.txt','w'); fprintf(fid, '%x \n', refsig); fclose (fid); The total size of refsig is 1x1024. thanks
From: Walter Roberson on 20 Jul 2010 00:05 Heman wrote: > can anyone tell me how to write the decimal data onto a text file in hex > format. http://www.mathworks.com/access/helpdesk/help/techdoc/ref/num2hex.html But see also http://www.mathworks.com/support/solutions/en/data/1-975VMF/?solution=1-975VMF if you need to convert IEEE 754 single precision from hex into single.
From: neil on 20 Jul 2010 00:07
"Heman " <kokahemant(a)hotmail.com> wrote in message <i22u17$b6s$1(a)fred.mathworks.com>... > "neil " <neil.iain(a)gmail.com> wrote in message <i22s8v$krb$1(a)fred.mathworks.com>... > > "Heman " <kokahemant(a)hotmail.com> wrote in message <i22rct$q05$1(a)fred.mathworks.com>... > > > hi frnds, > > > > > > can anyone tell me how to write the decimal data onto a text file in hex format. > > > > > > thanks > > > > Use the dec2hex function to convert to hex > > then something like > > fid = fopen('filename.dat','wt') > > fprintf(fid,'%s',dec2hex(10)); > > fclose(fid); > > > > You might want to play with the formatting of the fprintf command a bit. See the doc on that one > > Hey Neil, > > i tried the below code. It is writing but i dunno why but the written data is not in hexadecimal format. It is writing in exponential format. > > fid = fopen ('in_data.txt','w'); > fprintf(fid, '%x \n', refsig); > fclose (fid); > > The total size of refsig is 1x1024. > > thanks Sorry this is a bit of a pain. Firstly don't use %x use %s since you want to write the hex string and not the numerical representation of the string put your hex data in a cell array a = cellfun(@dec2hex,num2cell(1:200),'uniformoutput',false) fid = fopen('test.txt','wt') fprintf(fid,'%s\n',a{:}) fclose(fid) replace 1:200 with your decimal data matrix |