質問

I have a binary number which has 64 bits. But I want to print it in this order:

  • First line: 52 first bits
  • Second line: 11 Next bits
  • Third line: Last bit.

How can I do it with matlab? I have the code I am working with:

fid = fopen('unsigned_byte.bin','w');
fwrite(fid, 1.125,'float64');
fclose(fid);
s = dir('unsigned_byte.bin');
fprintf('Text File: %3d bytes\n',s.bytes)
fid = fopen('unsigned_byte.bin','r');
y = fread(fid,inf,'float64');
fprintf('%4.3f\n',y)
frewind(fid)
y = fread(fid,inf,'ubit1');
fprintf('%1d',[y])
fprintf('\n')  

Thanks

役に立ちましたか?

解決

Change the last two lines to:

fprintf('%1d',y(1:52))
fprintf('\n') 
fprintf('%1d',y(53:63))
fprintf('\n') 
fprintf('%1d',y(64))
fprintf('\n') 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top