Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个二进制数,我想将它保存在一个 txt 文件中。我的代码是:
fid=fopen('RT.txt','w') fprintf(fid,'%d',00111111100000000000000000000000 ); fclose(fid);
但是文件中保存的值是:1.111111e+029 我确实想将值保存为与二进制格式相同的值(32bit,就像我在这里写的数字一样)你能帮我吗?
00111111100000000000000000000000不是 MATLAB 中的二进制数。您可以将其保存为 string '00111111100000000000000000000000',或者如果要将二进制字符串转换为十进制数,则可以使用bin2dec('00111111100000000000000000000000'). 要将十进制数转换为二进制字符串(仍然是字符数组),请使用dec2bin(33).
00111111100000000000000000000000
'00111111100000000000000000000000'
bin2dec('00111111100000000000000000000000')
dec2bin(33)