数字信号处理《数字滤波器的MATLAB与FPGA实现》

仿真信号建立  ,输入信号和本振同频不同相,混频后的实现和量化.

%SimSigproduce.m

%set system parameters
fi=625000;
fc=625000;
Fs=5000000;
L=1024;
N=10;


%generate input signal
t=0:1/Fs:1/Fs*(L-1);
theta=rand()*2*pi;
si=sin(2*pi*fi*t+theta);
si=round(si*(2^(N-1)-1));


%generate LO Signal
sc=sin(2*pi*fc*t);
sc=round(sc*(2^(N-1)-1));


%sim mix input and plot
so=si.*sc;
sof=so-mean(so);
fso=abs(fft(so,L));

%
sc=sc/max(abs(sc));
si=si/max(abs(si));
so=so/max(abs(so));
sof=sof/max(abs(sof));
fso=fso/max(fso);

%

fso=[fso(L/2+1:L),fso(1:L/2)];
m=[-L/2:1:(L/2-1)]*Fs/L*(10^(-6));
t=t*(10^6);
subplot(221),plot(t(1:32),si(1:32)),title('10bit quantization','fontsize',8);
subplot(222),plot(t(1:32),so(1:32)),title('20bit quantization','fontsize',8);
subplot(223),plot(t(1:32),sof(1:32)),title('mixer filter the dc pon','fontsize',8);
subplot(224),plot(m,fso),title('mixer output signal H(w)','fontsize',8);

f_s=si/max(abs(si));
Q_s=round(f_s*(2^(N-1)-1));
%******************************%
%
%????Error using ==>fprintf
%Invalid file identifiter
fid=fopen('F:\matlab\Digital_Filter\01\SinIn.txt','w');
for k=1:length(Q_s)
    B_s=dec2bin(Q_s(k)+(Q_s(k)<0)*2^N,N);
    for j=1:N
        if B_s(j)=='1'
            tb=1;
        else
            tb=0;
        end
        fprintf(fid,'%d',tb);
    end
    fprintf(fid,'\r\n');
end
fprintf(fid,';');
fclose(fid);
        



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值