binary - MATLAB Decimal to ASCII -
binary - MATLAB Decimal to ASCII -
i trying convert 3x8 matrix ascii equivalent , save text file.
each row represents 8-bit binary number. steps follow create decimal value each row, utilize char()
convert decimal ascii.
this works ok alphanumeric inputs. input containing first 3 ascii characters (nul, soh , stx), resultant file empty.
the code is:
bin_3x8 = reshape(serial,8,[]).' dec = bin2dec(num2str(bin_3x8)) text = [char(dec).'] filesave = fopen(filename,'w'); fprintf(filesave,text); fclose(filesave);
output:
bin_3x8 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 dec = 0 1 2 text =
the matlab console shows text conversion empty, think might because can not print these characters. if write info file, file empty well.
any suggestions?
you can seek native2unicode
. set encoding ascii.
matlab binary ascii
Comments
Post a Comment