使用 matlab 生成 bin 文件
Matlab
close all; %关闭所有图形
clear; %清除所有变量
clc;
data = 1:1:1024;
fid = fopen('data.bin','wb'); % wb: 二进制写模式
fwrite(fid, data, 'int16'); % 按uint16(2字节)写入
dout = fread(fid, 'int16'); % 按uint16(2字节)写入
fclose(fid);
notepad++ 使用 HexEditor 显示二进制 bin 文件为

使用 Binary Viewer 显示二进制 bin 文件为

同一个文件 notepad++ 和 Binary Viewer 显示结果不一致,Binary Viewer 的显示更符合理论结果,notepad++ 存在 bug