首页->【MATLAB Usage 】

13 1

function [ ohtfir,htCoe,idata,BPFCoe] = ui_FIRHT(indata)
%UI_FIRHT 此处显示有关此函数的摘要
%   此处显示详细说明
%输入参数
    %indata:
        %输入带解调数据
%输出参数    
    %ohtfir
        %包络解调输出值
order_HT_FIR =32;          
Amp=[1 1];
freq=[0.05 0.95];
bw=freq;
htCoe=firls(order_HT_FIR,freq,Amp,'Hilbert');
BPFCoe=fir1(order_HT_FIR,bw,'BANDPASS');

%整理 ht-filter coefficient
 for cnti=1:order_HT_FIR+1
     
      if abs(htCoe(cnti)) <=1e-10;
            htCoe(cnti)=0;
      end
      
      if abs(BPFCoe(cnti)) <=1e-10;
            BPFCoe(cnti)=0;
      end
 end
 
 
%for test
% fs=fs/1e6;
% [h,w]=freqz(htCoe,1,512,fs);
% figure(1);
% plot(w,20*log10(abs(h)));
% axis([0 8.88 -50 10]);
% xlabel('f/MHz');
% ylabel('Magnitude/dB');
% grid on;
[row,SampleLen]=size(indata);
[~,coeLen]=size(htCoe);

idata=[zeros(32,SampleLen);indata;zeros(31,SampleLen)];
[rowa,SampleLena]=size(idata);
odata_HTFIR=zeros(rowa,SampleLen);
odata_BPF=zeros(rowa,SampleLen);

if mod(coeLen,2)==1
    bufferLen=(coeLen+1)/2;
else
    bufferLen=coeLen/2;
end
sumtdata=zeros(bufferLen,SampleLen);
% BPFCoe=fir1(order_HT_FIR,bw,'BANDPASS');

%for debug
% [h,w]=freqz(BPFCoe,1,512,fs);
% figure(1);
% plot(w,20*log10(abs(h)));
% axis([0 8.88e6 -50 10]);
% xlabel('f/MHz');
% ylabel('Magnitude/dB');
% grid on;

cnti=1;
%for HTFIR
for cnt=1:rowa-coeLen+1   
    tempdata=idata(cnt:coeLen+cnt-1,:);
    for order =1:bufferLen-1
        sumtdata(order,:)=tempdata(coeLen-order+1,:)-tempdata(order,:);
    end
    sumtdata(bufferLen,:)=tempdata(bufferLen,:);
    odata_HTFIR(cnti,:)=htCoe(1,1:bufferLen)*sumtdata;   
    cnti=cnti+1;
end

sumtdata=zeros(bufferLen,SampleLen);
%for BPF
cnti=1;
for cnt=1:rowa-coeLen+1  
    tempdata=idata(cnt:coeLen+cnt-1,:);
    for order =1:bufferLen-1
        sumtdata(order,:)=tempdata(order,:)+tempdata(coeLen-order+1,:);
    end
    sumtdata(bufferLen,:)=tempdata(bufferLen,:);
    odata_BPF(cnti,:)=BPFCoe(1,1:bufferLen)*sumtdata;
    cnti=cnti+1;
end
ohtfir=sqrt(odata_BPF.^2+odata_HTFIR.^2);
% id=idata;
N=1:rowa;
plot(N,odata_BPF,N,ohtfir);
grid on;
%ohtfir=ohtfir/max(ohtfir);
end



楼主可见

  1. shwnyoo 1#

    一种新的基于ht-fir 的包络解调