使用matlab读取txt文件中的2进制数据
通过modelsim将仿真的结果写入txt文件中,
通过textscan函数将2进制数据从txt文本中读出,
通过bin2dec函数将数据从2进制转为10进制,
通过plot函数将数据以曲线形式显示。
代码如下:
clc;
clear;% 以二进制形式读取路径中的TXT文件
fid = fopen('E:\502\TXL\sim_htpa\testbench\tb_sensitivity_coefficient_cal\output_file\pix_cij_data_from_fpga.txt','rb');
data = textscan(fid,'%s');
data1 = zeros(5120,1);% 将所有数据转换为十进制数据
for i = 1 : 5120data1(i) = bin2dec(data{1,1}{i,1});
end% 对数据进行画线处理
plot(data1)