当前位置: 首页 > news >正文

MATLAB代码来生成根升余弦滤波器,并绘制其时域和频域特性

根升余弦滤波器完整实现

%% 根升余弦滤波器生成与分析clear all;close all;clc;%% 参数设置Fs=1000;% 采样频率 (Hz)T=1;% 符号周期 (s)sps=10;% 每符号采样点数beta=0.5;% 滚降因子 (0~1)filter_span=6;% 滤波器跨度 (符号数)%% 生成根升余弦滤波器% 方法1: 使用rcosdesign函数 (推荐)h_rc=rcosdesign(beta,filter_span,sps,'sqrt');% 方法2: 手动实现 (备用方法)% t = (-filter_span*T/2 : 1/Fs : filter_span*T/2) + 1e-8; % 避免除零% h_rc_manual = manual_root_raised_cosine(t, T, beta);%% 时域分析t_filter=(-filter_span*sps/2:filter_span*sps/2)/(sps/T);figure('Position',[100,100,1200,800]);% 时域波形subplot(2,3,1);stem(t_filter,h_rc,'b','filled','MarkerSize',4);hold on;plot(t_filter,h_rc,'r-','LineWidth',1.5);grid on;xlabel('时间 (符号周期)');ylabel('幅度');title('根升余弦滤波器时域响应');legend('采样点','包络','Location','best');% 滤波器冲激响应细节subplot(2,3,2);plot(t_filter,h_rc,'b-','LineWidth',2);grid on;xlabel('时间 (符号周期)');ylabel('幅度');title('滤波器冲激响应');xlim([-3,3]);% 眼图模拟subplot(2,3,3);% 生成随机数据并滤波data=randi([01],1,100)*2-1;% BPSK信号upsampled_data=upsample(data,sps);tx_signal=conv(upsampled_data,h_rc,'same');% 绘制眼图plot_eye_diagram(tx_signal,sps,2);title('发射信号眼图');%% 频域分析% 计算频率响应N_fft=1024;H_rc=fftshift(fft(h_rc,N_fft));f=(-N_fft/2:N_fft/2-1)*(Fs/N_fft)/(1/T);% 归一化频率% 幅度响应subplot(2,3,4);plot(f,20*log10(abs(H_rc)/max(abs(H_rc))),'b-','LineWidth',2);grid on;xlabel('归一化频率 (fT)');ylabel('幅度 (dB)');title('根升余弦滤波器幅度响应');xlim([-2,2]);ylim([-80,5]);% 相位响应subplot(2,3,5);phase_response=angle(H_rc);phase_response_unwrapped=unwrap(phase_response);plot(f,phase_response_unwrapped,'r-','LineWidth',2);grid on;xlabel('归一化频率 (fT)');ylabel('相位 (弧度)');title('相位响应');xlim([-2,2]);% 群延迟subplot(2,3,6);group_delay=-diff(phase_response_unwrapped)./diff(f*2*pi);plot(f(1:end-1),group_delay,'g-','LineWidth',2);grid on;xlabel('归一化频率 (fT)');ylabel('群延迟 (样本)');title('群延迟响应');xlim([-2,2]);%% 不同滚降因子的比较figure('Position',[100,100,1000,600]);beta_values=[0.2,0.5,0.8,1.0];colors=['b','r','g','m'];t_compare=(-filter_span*sps/2:filter_span*sps/2)/(sps/T);subplot(1,2,1);hold on;fori=1:length(beta_values)h_temp=rcosdesign(beta_values(i),filter_span,sps,'sqrt');plot(t_compare,h_temp,colors(i),'LineWidth',2,...'DisplayName',['\beta = ',num2str(beta_values(i))]);endgrid on;xlabel('时间 (符号周期)');ylabel('幅度');title('不同滚降因子的时域响应');legend('show');xlim([-3,3]);subplot(1,2,2);hold on;fori=1:length(beta_values)h_temp=rcosdesign(beta_values(i),filter_span,sps,'sqrt');H_temp=fftshift(fft(h_temp,N_fft));f_compare=(-N_fft/2:N_fft/2-1)*(Fs/N_fft)/(1/T);plot(f_compare,20*log10(abs(H_temp)/max(abs(H_temp))),...colors(i),'LineWidth',2,...'DisplayName',['\beta = ',num2str(beta_values(i))]);endgrid on;xlabel('归一化频率 (fT)');ylabel('幅度 (dB)');title('不同滚降因子的频域响应');legend('show');xlim([-2,2]);ylim([-80,5]);%% ISI性能分析figure('Position',[100,100,800,400]);% 测试符号间干扰test_symbols=[0,0,1,0,0];% 单个脉冲test_signal_upsampled=upsample(test_symbols,sps);filtered_signal=conv(test_signal_upsampled,h_rc,'same');% 找到峰值位置[~,peak_idx]=max(filtered_signal);sampling_points=peak_idx:sps:length(filtered_signal);subplot(1,2,1);plot(filtered_signal,'b-','LineWidth',2);hold on;stem(sampling_points,filtered_signal(sampling_points),'ro','filled');grid on;xlabel('采样点');ylabel('幅度');title('单个脉冲的滤波器响应');legend('滤波器输出','采样时刻');% ISI分析 - 采样时刻的值subplot(1,2,2);isi_samples=filtered_signal(sampling_points);stem(0:length(isi_samples)-1,isi_samples,'b','filled');hold on;% 标记主瓣和旁瓣plot([2,2],[0,max(isi_samples)],'r--','LineWidth',1.5);text(2.2,max(isi_samples)*0.8,'主瓣','Color','r');grid on;xlabel('符号索引');ylabel('幅度');title('采样时刻的ISI分析');%% 自定义函数定义functionplot_eye_diagram(signal,samples_per_symbol,num_eyes)% 绘制眼图eye_length=samples_per_symbol*num_eyes;num_segments=floor(length(signal)/eye_length)-1;hold on;fori=1:num_segments start_idx=(i-1)*eye_length+1;end_idx=start_idx+eye_length-1;segment=signal(start_idx:end_idx);time_axis=(0:length(segment)-1)/samples_per_symbol;plot(time_axis,segment,'b-','LineWidth',0.5);endxlabel('时间 (符号周期)');ylabel('幅度');grid on;hold off;endfunctionh=manual_root_raised_cosine(t,T,beta)% 手动计算根升余弦滤波器h=zeros(size(t));fori=1:length(t)t_val=t(i);ifabs(t_val)==T/(4*beta)h(i)=(beta/sqrt(2*T))*...((1+2/pi)*sin(pi/(4*beta))+(1-2/pi)*cos(pi/(4*beta)));elseift_val==0h(i)=(1/sqrt(T))*(1+beta*(4/pi-1));elseterm1=sin(pi*(1-beta)*t_val/T+4*beta*t_val/T*cos(pi*(1+beta)*t_val/T));term2=pi*t_val/T*(1-(4*beta*t_val/T).^2);h(i)=(1/sqrt(T))*term1./term2;endendend%% 滤波器特性总结fprintf('=== 根升余弦滤波器特性总结 ===\n');fprintf('滚降因子 β: %.2f\n',beta);fprintf('滤波器长度: %d 个采样点\n',length(h_rc));fprintf('每符号采样点数: %d\n',sps);fprintf('滤波器跨度: %d 个符号\n',filter_span);% 计算关键参数energy=sum(h_rc.^2);fprintf('滤波器能量: %.4f\n',energy);% 检查奈奎斯特准则sampling_offset=round(length(h_rc)/2)+sps;isi_values=h_rc(sampling_offset:sps:end);isi_power=sum(isi_values.^2)-h_rc(round(length(h_rc)/2))^2;fprintf('ISI功率: %.6f\n',isi_power);

特性分析

1.时域特性

  • 主瓣宽度:与滚降因子β相关
  • 旁瓣衰减:决定符号间干扰(ISI)大小
  • 过零点:在整数倍符号周期处过零,满足奈奎斯特准则

2.频域特性

  • 带宽B = (1 + β) / (2T) Hz
  • 滚降特性:平滑的过渡带
  • 带外抑制:良好的频谱利用率

3.滚降因子影响

  • β较小(0.2-0.3):频谱效率高,但对定时误差敏感
  • β中等(0.4-0.6):平衡频谱效率和抗干扰能力
  • β较大(0.7-1.0):抗干扰能力强,但频谱效率低

参考代码 根升余弦滤波器www.3dddown.com/csa/82526.html

实际应用

  1. 无线通信:常用β=0.35(卫星)或β=0.5(蜂窝)
  2. 有线通信:根据信道特性选择β值
  3. 数字电视:通常使用较小的滚降因子
http://www.cnnetsun.cn/news/127364.html

相关文章:

  • 继何恺明DyT后,LayerNorm再遭暴击!简单erf函数竟成Transformer新宠
  • C语言链表2
  • 蜣螂优化(DBO)算法在工程实际中求目标函数最小值的例子:压力容器设计成本最小化的4变量4约束...
  • 12、游戏内存中常见数据结构解析
  • 21、游戏响应式黑客技术全解析
  • 26、游戏隐藏与反检测技术全解析
  • Kotaemon网络安全问答:CVE漏洞快速查询
  • Kotaemon能否自动识别问题紧急程度?
  • 复杂时序场景的突围:金仓数据库是凭借什么超越InfluxDB?
  • 特价股票投资中的跨境投资策略与风险管理
  • 为分析经理制定全面的仪表板策略
  • MATLAB实现神经网络的模式识别
  • 17、在 Linux 系统中运行 Windows 程序及优化工作流
  • Kotaemon索引构建优化:FAISS vs HNSW性能对比
  • Kotaemon在低资源环境下的轻量化改造方案
  • 16、企业 Linux 桌面迁移与后台基础设施搭建指南
  • 19、数据迁移与备份:从 Windows 到 Linux 的全面指南
  • Kotaemon销售谈判策略建议:促成交易技巧
  • 特征工程中的特征构造技巧:大数据分析的创新实践
  • 32、Linux在不同场景下的应用优势与案例分析
  • 26、深入了解GNU Lesser General Public License
  • Hive实战任务 - 9.2 统计总分与平均分
  • Hive实战任务 - 9.3 实现学生信息排序和统计
  • 1、深入解析 Windows 2000 终端服务与 Citrix MetaFrame 配置
  • 10个降AI率工具推荐,本科生高效降AIGC指南
  • 8个降AI率工具推荐,本科生高效避坑指南
  • 10 个高效降AI率工具,继续教育学生必备!
  • 19、Windows 应用数据管理全解析
  • Kotaemon税务咨询助手知识图谱构建
  • linux下执行pg数据的sql文件,报错error:permission denied for schema plat