资源简介
数字下变频器的matlab仿真,包括基带信号的调制,然后经过混频模块、CIC模块、FIR模块最后得到基带信号的过程。有详细的注释,很容易理解。
代码片段和文件信息
clc; clear;close all;
%%%%%%%%%%%%%%%%%%%
%% 1.输入参数设置 %%
%%%%%%%%%%%%%%%%%%%
% 参数配置;参数是如何确定的?????????????????
fs = 100e6; % 采样频率128MHz;
f = 72e6; % 载波频率1MHz;72M
d_cic = 8; % CIC滤波器抽取率2<=D<=512;
q_cic = 5; % CIC滤波器级数q
d_fir1 = 4; % FIR1滤波器抽取率;
d_fir2 = 2; % FIR2滤波器抽取率;
% 设置采样点数;
N = 128*100*8*2;
n = 0:N-1;
% 生成输入信号;
x_in =cos(2*pi*5e3*n/fs); %基频10KHz; cos(wt){w=2*pi*f t=n/fs}
%x_in_q = round(x_in*2^31)/2^31;
x_in_q = round(x_in*2^7)/2^7;
% 计算频率分辨率;
fd = fs/N; % 采样频率——fs;采样点数——N;
display(fd);
disp(‘Hz‘);
% 生成加汉宁窗;
w = hann(N‘symmetric‘); %symmetric periodic 两种方式没区别
% 加汉宁窗的傅里叶变换;
fft_x_in = fft(x_in_q.*w‘);% .*为矩阵点乘
%频谱修正;
fft_x_in = fft_x_in(1:N/2+1)/N*4;
A = abs(fft_x_in); %abs 求绝对值
%结果显示;
figure(10);
subplot(211);
plot(n/fsx_in); %n=0;N-1 N=128*100*8*2
xlabel(‘时间t/s‘);ylabel(‘基带信号幅度‘);grid on;title(‘基带信号波形‘);
f0 = fs*(0:N/2)/N/1e6;%归一化 对称只需要用到一半的点
subplot(212);
plot(f020*log10(A));
axis([0 0.5 -inf inf]);
xlabel(‘频率(MHz)‘);ylabel(‘功率谱‘);grid on;title(‘基带信号频谱‘);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 2.调制 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FM_out = 0.2685*x_in.*cos(2*pi*f*n/fs)+1.6*noise; % 基频1KHz+1.5KHz+5KHz,载频1M,噪声Vppn = 10;
f_carry = cos(2*pi*f*n/fs); % 载波频率 f=72Mhz
f_carry_q =round(f_carry*2^7)/2^7; % 载频8位量化(最高位为符号位)round 为取最近的整数
FM_out = x_in_q.*f_carry_q; % 基频1KHz+1.5KHz+5KHz,载频1M,噪声Vppn = 10;
FM_out_noise = awgn(FM_out20); %y = awgn(xsnr) x信号,snr是信噪比
FM_out = 0.8537*FM_out/max(FM_out); % 归一化,满刻度量化(为什么要乘上0.8537)
FM_out_q = fix(FM_out*2^7)/2^7; % (fix舍小数取整)输入调制信号经过16bit的量化
% 加汉宁窗的傅里叶变换;
fft_FM_out = fft(FM_out_q.*w‘);
% 频谱修正;
fft_FM_out = fft_FM_out(1:N/2+1)/N*4;
A = abs(fft_FM_out);
% 结果显示;
figure(21);
subplot(211);
plot(n/fsFM_out_q);
xlabel(‘时间t/s‘);ylabel(‘调制信号幅度‘);grid on;title(‘调制信号波形‘);
% subplot(312);
% plot(f020*log10(A));
% xlabel(‘频率(MHz)‘);ylabel(‘功率谱‘);grid on;title(‘未修正调制信号频谱‘);
subplot(212);
plot(f020*log10(A));
axis([27.8 29.2 -inf 0]);
xlabel(‘频率(MHz)‘);ylabel(‘功率谱‘);grid on;title(‘修正调制信号频谱‘);
% 生成Modelsim仿真输入数据;
H=FM_out_q*2^15;
% H=ceil(H);
fid=fopen(‘ddc_test_in.dat‘‘wt‘);
% fprintf(fid‘%4x\n‘H+(H<0)*2^16);
fprintf(fid‘%4x\n‘H+(H<0)*2^16);
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%% 3.NCO混频 %%
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 混频I支路输出;
FM_out_int = floor(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12487 2014-05-14 11:51 ddc_purechangeone.m
相关资源
- Pattern Recognition and Machine Learning(高清
- MATLAB 编程 第二版 Stephen J. Chapman 著
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- HDB3码、AMI码的MATLAB实现
- 3点GPS定位MATLAB仿真
- MATLAB数字信号处理85个实用案例精讲入
- matlab从入门到精通pdf94795
- 欧拉放大论文及matlab代码
- 跳一跳辅助_matlab版本
- 全面详解LTE MATLAB建模、仿真与实现
- MIMO-OFDM无线通信技术及MATLAB实现_孙锴
- MATLAB Programming for Engineers 4th - Chapman
- matlab 各种谱分析对比
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- MATLAB车流仿真 包括跟驰、延误
- matlab空间桁架计算程序
- 基于MATLAB的图像特征点匹配和筛选
- DMA-TVP-FAVAR
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- newmark法源程序
- 传统关联成像、计算鬼成像matlab
- pri传统分选算法
- 摆动滚子推杆盘形凸轮设计
- 医学图像重建作业matlab源码
- Matlab实现混沌系统的控制
- 检测疲劳驾驶
- Matlab锁相环仿真-Phase Locked Loop.rar
评论
共有 条评论