⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 biase2buma.m

📁 可以地实现偏置码到补码的转换
💻 M
字号:
% function biase2buma
%实现偏置码到补码到转换
str1='请选择您要转化为补码的偏置码信号';
[xxsname,xxspath]=uigetfile('*.dat',str1);
spec_path_name = fullfile(xxspath,xxsname);
spec_path_name = strcat(spec_path_name,'.dat');    
 
spec_path_name=strrep(spec_path_name,'.dat.dat','.dat');
[fida,message] = fopen(spec_path_name,'rb');
%给出文件的长度  
fseek(fida,0,1);        %从文件尾开始移动,令移动量为0,相当于指针指向文件最后一个字节
file_length=ftell(fida) %ftell给出当前指针位置距离文件首的间距,就是文件大小了
fseek(fida,0,-1);%  文件指针移回到文件首
prompt={'数据采样率为: 单位(MHz)'};
fstitle='给出该二进制文件相应的采样率';
default_fs={'100'};
fs=inputdlg(prompt,fstitle,1,default_fs);
 
if isempty(fs)
   warndlg('您取消了本次操作',fstitle);
end
fs=str2num(fs{1});  
fs=fs*1000000;
%提示用户给出保存文件名及其路径名
[yysname,yyspath]=uiputfile('buma.dat','生成的补码文件保存为:');
save_name = fullfile(yyspath,yysname);  


%将文件分为多个block
block=1024000;
base_point_number=ceil(file_length/block)   
hh_0=waitbar(0,'please wait...');
for outer_circle=1:base_point_number   %最外层循环
   not_read_length=file_length-ftell(fida)
    if not_read_length<=block
       [inputdata1,count] = fread(fida,not_read_length,'uint8');
    else   
       [inputdata1,count] = fread(fida,block,'uint8');
    end
    
    cca=inputdata1-128; 
    fid2 = fopen(save_name,'a+');
    count=fwrite(fid2,cca ,'int8');
    fclose(fid2);

waitbar(outer_circle/base_point_number,hh_0)
end  %最外层循环

close(hh_0);
fclose(fida);
%文件保存好后给出提示
str11='偏置码转化为补码并保存为';
str12=save_name;
msg1=strcat(str11,str12);
msgbox(msg1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -