基于matlab实现OFDM的编码

合集下载

(完整版)OFDMmatlab实现

(完整版)OFDMmatlab实现

close all;carrier_count=200;%子载波数symbols_per_carrier=12;%每子载波含符号数bits_per_symbol=4;%每符号含比特数,16QAM调制IFFT_bin_length=512;%FFT点数PrefixRatio=1/4;%保护间隔与OFDM数据的比例1/6~1/4GI=PrefixRatio*IFFT_bin_length ;%每一个OFDM符号添加的循环前缀长度为1/4*IFFT_bin_length 即保护间隔长度为128beta=1/32;%窗函数滚降系数GIP=beta*(IFFT_bin_length+GI);%循环后缀的长度20SNR=15; %信噪比dB%==================================================%================信号产生=================================== baseband_out_length = carrier_count * symbols_per_carrier * bits_per_symbol;%所输入的比特数目carriers = (1:carrier_count) + (floor(IFFT_bin_length/4) - floor(carrier_count/2));%共轭对称子载波映射复数数据对应的IFFT点坐标conjugate_carriers = IFFT_bin_length - carriers + 2;%共轭对称子载波映射共轭复数对应的IFFT点坐标rand( 'state',0);baseband_out=round(rand(1,baseband_out_length));%输出待调制的二进制比特流%==============16QAM调制====================================complex_carrier_matrix=qam16(baseband_out);%列向量complex_carrier_matrix=reshape(complex_carrier_matrix',carrier_count,symbols_per_car rier)';%symbols_per_carrier*carrier_count 矩阵figure(1);plot(complex_carrier_matrix,'*r');%16QAM调制后星座图axis([-4, 4, -4, 4]);grid on%=================IFFT===========================IFFT_modulation=zeros(symbols_per_carrier,IFFT_bin_length);%添0组成IFFT_bin_length IFFT 运算IFFT_modulation(:,carriers ) = complex_carrier_matrix ;%未添加导频信号,子载波映射在此处IFFT_modulation(:,conjugate_carriers ) = conj(complex_carrier_matrix);%共轭复数映射%========================================================stem(0:IFFT_bin_length-1, abs(IFFT_modulation(2,1:IFFT_bin_length)),'b*-')%第一个OFDM符号的频谱grid onaxis ([0 IFFT_bin_length -0.5 4.5]);ylabel('Magnitude');xlabel('IFFT Bin');title('OFDM Carrier Frequency Magnitude');figure(3);plot(0:IFFT_bin_length-1, (180/pi)*angle(IFFT_modulation(2,1:IFFT_bin_length)), 'go') hold onstem(0:carriers-1, (180/pi)*angle(IFFT_modulation(2,1:carriers)),'b*-');%第一个OFDM符号的相位stem(0:conjugate_carriers-1,(180/pi)*angle(IFFT_modulation(2,1:conjugate_carriers)),'b*-');axis ([0 IFFT_bin_length -200 +200])grid onylabel('Phase (degrees)')xlabel('IFFT Bin')title('OFDM Carrier Phase')%================================================================= signal_after_IFFT=ifft(IFFT_modulation,IFFT_bin_length,2);%OFDM调制即IFFT变换time_wave_matrix =signal_after_IFFT;%时域波形矩阵,行为每载波所含符号数,列ITTF 点数,N个子载波映射在其内,每一行即为一个OFDM符号figure(4);subplot(3,1,1);plot(0:IFFT_bin_length-1,time_wave_matrix(2,:));%第一个符号的波形axis([0, 700, -0.2, 0.2]);grid on;ylabel('Amplitude');xlabel('Time');title('OFDM Time Signal, One Symbol Period');%===========================================================%=====================添加循环前缀与后缀====================================XX=zeros(symbols_per_carrier,IFFT_bin_length+GI+GIP);for k=1:symbols_per_carrier;for i=1:IFFT_bin_length;XX(k,i+GI)=signal_after_IFFT(k,i);endfor i=1:GI;XX(k,i)=signal_after_IFFT(k,i+IFFT_bin_length-GI);%添加循环前缀endfor j=1:GIP;XX(k,IFFT_bin_length+GI+j)=signal_after_IFFT(k,j);%添加循环后缀endendtime_wave_matrix_cp=XX;%添加了循环前缀与后缀的时域信号矩阵,此时一个OFDM符号长度为IFFT_bin_length+GI+GIP=660subplot(3,1,2);plot(0:length(time_wave_matrix_cp)-1,time_wave_matrix_cp(2,:));%第一个符号添加循环前缀后的波形axis([0, 700, -0.2, 0.2]);grid on;ylabel('Amplitude');xlabel('Time');title('OFDM Time Signal with CP, One Symbol Period');%==============OFDM符号加窗==========================================windowed_time_wave_matrix_cp=zeros(1,IFFT_bin_length+GI+GIP);for i = 1:symbols_per_carrierwindowed_time_wave_matrix_cp(i,:) =real(time_wave_matrix_cp(i,:)).*rcoswindow(beta,IFFT_bin_length+GI)';%加窗升余弦窗endsubplot(3,1,3);plot(0:IFFT_bin_length-1+GI+GIP,windowed_time_wave_matrix_cp(2,:));%第一个符号的波形axis([0, 700, -0.2, 0.2]);grid on;ylabel('Amplitude');xlabel('Time');title('OFDM Time Signal Apply a Window , One Symbol Period');%========================生成发送信号,并串变换==================================================windowed_Tx_data=zeros(1,symbols_per_carrier*(IFFT_bin_length+GI)+GIP); windowed_Tx_data(1:IFFT_bin_length+GI+GIP)=windowed_time_wave_matrix_cp(1,:); for i = 1:symbols_per_carrier-1 ;windowed_Tx_data((IFFT_bin_length+GI)*i+1:(IFFT_bin_length+GI)*(i+1)+GIP)=window ed_time_wave_matrix_cp(i+1,:);%并串转换,循环后缀与循环前缀相叠加end%=======================================================Tx_data_withoutwindow=reshape(time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI+GIP),1)';%没有加窗,只添加循环前缀与后缀的串行信号Tx_data=reshape(windowed_time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI +GIP),1)';%加窗后循环前缀与后缀不叠加的串行信号%================================================================= temp_time1 = (symbols_per_carrier)*(IFFT_bin_length+GI+GIP);%加窗后循环前缀与后缀不叠加发送总位数figure (5)subplot(2,1,1);plot(0:temp_time1-1,Tx_data );%循环前缀与后缀不叠加发送的信号波形grid onylabel('Amplitude (volts)')xlabel('Time (samples)')title('OFDM Time Signal')temp_time2 =symbols_per_carrier*(IFFT_bin_length+GI)+GIP;subplot(2,1,2);plot(0:temp_time2-1,windowed_Tx_data);%循环后缀与循环前缀相叠加发送信号波形grid onylabel('Amplitude (volts)')xlabel('Time (samples)')title('OFDM Time Signal')%=================未加窗发送信号频谱==================================symbols_per_average = ceil(symbols_per_carrier/5);%符号数的1/5,10行avg_temp_time = (IFFT_bin_length+GI+GIP)*symbols_per_average;%点数,10行数据,10个符号averages = floor(temp_time1/avg_temp_time);average_fft(1:avg_temp_time) = 0;%分成5段for a = 0:(averages-1)subset_ofdm = Tx_data_withoutwindow(((a*avg_temp_time)+1):((a+1)*avg_temp_time));%subset_ofdm_f = abs(fft(subset_ofdm));%将发送信号分段求频谱average_fft = average_fft + (subset_ofdm_f/averages);%总共的数据分为5段,分段进行FFT,平均相加endaverage_fft_log = 20*log10(average_fft);figure (6)subplot(2,1,1);plot((0:(avg_temp_time-1))/avg_temp_time, average_fft_log)%归一化0/avg_temp_time : (avg_temp_time-1)/avg_temp_timehold onplot(0:1/IFFT_bin_length:1, -35, 'rd')grid onaxis([0 0.5 -40 max(average_fft_log)])ylabel('Magnitude (dB)')xlabel('Normalized Frequency (0.5 = fs/2)')title('OFDM Signal Spectrum without windowing')%===============加窗的发送信号频谱================================= symbols_per_average = ceil(symbols_per_carrier/5);%符号数的1/5,10行avg_temp_time = (IFFT_bin_length+GI+GIP)*symbols_per_average;%点数,10行数据,10个符号averages = floor(temp_time1/avg_temp_time);average_fft(1:avg_temp_time) = 0;%分成5段for a = 0:(averages-1)subset_ofdm = Tx_data(((a*avg_temp_time)+1):((a+1)*avg_temp_time));%利用循环前缀后缀未叠加的串行加窗信号计算频谱subset_ofdm_f = abs(fft(subset_ofdm));%分段求频谱average_fft = average_fft + (subset_ofdm_f/averages);%总共的数据分为5段,分段进行FFT,平均相加endaverage_fft_log = 20*log10(average_fft);subplot(2,1,2)plot((0:(avg_temp_time-1))/avg_temp_time, average_fft_log)%归一化0/avg_temp_time : (avg_temp_time-1)/avg_temp_timehold onplot(0:1/IFFT_bin_length:1, -35, 'rd')grid onaxis([0 0.5 -40 max(average_fft_log)])ylabel('Magnitude (dB)')xlabel('Normalized Frequency (0.5 = fs/2)')title('Windowed OFDM Signal Spectrum')%====================添加噪声============================================Tx_signal_power = var(windowed_Tx_data);%发送信号功率linear_SNR=10^(SNR/10);%线性信噪比noise_sigma=Tx_signal_power/linear_SNR;noise_scale_factor = sqrt(noise_sigma);%标准差sigmanoise=randn(1,((symbols_per_carrier)*(IFFT_bin_length+GI))+GIP)*noise_scale_factor; %产生正态分布噪声序列%noise=wgn(1,length(windowed_Tx_data),noise_sigma,'complex');%产生复GAUSS白噪声信号Rx_data=windowed_Tx_data +noise;%接收到的信号加噪声%=====================接收信号串/并变换去除前缀与后缀==========================================Rx_data_matrix=zeros(symbols_per_carrier,IFFT_bin_length+GI+GIP);for i=1:symbols_per_carrier;Rx_data_matrix(i,:)=Rx_data(1,(i-1)*(IFFT_bin_length+GI)+1:i*(IFFT_bin_length+GI)+GI P);%串并变换endRx_data_complex_matrix=Rx_data_matrix(:,GI+1:IFFT_bin_length+GI);%去除循环前缀与循环后缀,得到有用信号矩阵%============================================================%==== ============================================================%==============================================================% OFDM解码16QAM解码%=================FFT变换=================================Y1=fft(Rx_data_complex_matrix,IFFT_bin_length,2);%OFDM解码即FFT变换Rx_carriers=Y1(:,carriers);%除去IFFT/FFT变换添加的0,选出映射的子载波Rx_phase =angle(Rx_carriers);%接收信号的相位Rx_mag = abs(Rx_carriers);%接收信号的幅度figure(7);polar(Rx_phase, Rx_mag,'bd');%极坐标坐标下画出接收信号的星座图%================================================================== ====[M, N]=pol2cart(Rx_phase, Rx_mag);Rx_complex_carrier_matrix = complex(M, N);figure(8);plot(Rx_complex_carrier_matrix,'*r');%XY坐标接收信号的星座图axis([-4, 4, -4, 4]);grid on%====================16qam解调==================================================Rx_serial_complex_symbols =reshape(Rx_complex_carrier_matrix',size(Rx_complex_carrier_matrix,1)*size(Rx_complex_carrier_matrix,2),1)' ;Rx_decoded_binary_symbols=demoduqam16(Rx_serial_complex_symbols);%============================================================ baseband_in = Rx_decoded_binary_symbols;figure(9);subplot(2,1,1);stem(baseband_out(1:100));subplot(2,1,2);stem(baseband_in(1:100));%================误码率计算=============================================bit_errors=find(baseband_in ~=baseband_out);bit_error_count = size(bit_errors, 2)ber=bit_error_count/baseband_out_length。

MATLAB OFDM卷积编码程序及代码

MATLAB OFDM卷积编码程序及代码

%bin22deci.mfunction y=bin22deci(x)%将二进制数转化为十进制数t=size(x,2);y=(t-1:-1:0);y=2.^y;y=x*y';%************************end of file***********************************%comb.m%AWGN加噪声程序function[iout,qout]=comb(idata,qdata,attn)%******************variables*************************%idata:输入I信道数据%qdata:输入Q信道数据%iout输出I信道数据%qout输出Q信道数据%attn:由信噪比导致的衰减系数%******************************************************iout=randn(1,length(idata)).*attn;qout=randn(1,length(qdata)).*attn;iout=iout+idata(1:length(idata));qout=qout+qdata(1:length(qdata));%************************end of file***********************************%crdemapping.m%数据逆映射载波程序function[iout,qout]=crdemapping(idata,qdata,fftlen,nd);%******************variables*************************%idata:输入I信道的数据%qdata:输入Q信道的数据%iout:输出I信道的数据%qout:输出Q信道的数据%fftlen:FFT的长度%nd:OFDM符号数%*****************************************************iout(1:26,:)=idata(2:27,:);qout(1:26,:)=qdata(2:27,:);iout(27:52,:)=idata(39:64,:);qout(27:52,:)=qdata(39:64,:);%********************end of file***************************%crmapping.m%数据映射载波程序function[iout,qout]=crmapping(idata,qdata,fftlen,nd);%******************variables*************************%idata:输入I信道的数据%qdata:输入Q信道的数据%iout:输出I信道的数据%qout:输出Q信道的数据%fftlen:FFT的长度%nd:OFDM符号数%*****************************************************iout=zeros(fftlen,nd);qout=zeros(fftlen,nd);iout(2:27,:)=idata(1:26,:);qout(2:27,:)=qdata(1:26,:);iout(39:64,:)=idata(27:52,:);qout(39:64,:)=qdata(27:52,:);%********************end of file***************************%deci22bin.mfunction y=deci22bin(x,t)%十进制数x转化为二进制数,二进制数至少表示为t位y=zeros(size(x,1),t);for j=1:size(x,1)i=1;while x(j)>=0&i<=ty(j,i)=rem(x(j),2);%x(j)为偶数时,y(j,i)为0;反之为1x(j)=(x(j)-y(j,i))/2;i=i+1;endy(j,:)=y(j,t:-1:1);%倒序排列end%************************end of file***********************************%giins1.m%插入保护间隔程序function[iout,qout]=giins1(idata,qdata,fftlen,gilen,nd);%******************变量*************************%idata:输入I信道数据%qdata:输入Q信道数据%iout:输出I信道数据%qout:输出Q信道数据%fftlen:FFT长度(points)%gilen:保护间隔长度(points)%*****************************************************idata1=reshape(idata,fftlen,nd);qdata1=reshape(qdata,fftlen,nd);idata2=[idata1(fftlen-gilen+1:fftlen,:);idata1];qdata2=[qdata1(fftlen-gilen+1:fftlen,:);qdata1];iout=reshape(idata2,1,(fftlen+gilen)*nd);qout=reshape(qdata2,1,(fftlen+gilen)*nd);%********************end of file***************************%qpskdemod1.m%QPSK解调程序function[demodata]=qpskdemod1(idata,qdata,para,nd,ml)%******************variables*************************%idata:输入I信道数据%qdata:数据Q信道数据%demodata:解调后数据(para-by-nd matrix)%para:并行信道数%nd:符号数%ml:调制数%(QPSK->2 16QAM->4)%*****************************************************demodata=zeros(para,ml*nd);demodata((1:para),(1:ml:ml*nd-1))=idata((1:para),(1:nd))>=0; demodata((1:para),(2:ml:ml*nd))=qdata((1:para),(1:nd))>=0;%************************end of file***********************************%qpskmod1.m%QPSK调制程序function[iout,qout]=qpskmod1(paradata,para,nd,ml)%******************variables*************************%paradata:输入数据%iout:输出数据I%qout:输出数据Q%para:并行信道数%nd:数据数%ml:调制数%(QPSK->2 16QAM->4)%*****************************************************m2=ml./2;paradata2=paradata.*2-1;count2=0;for jj=1:ndisi=zeros(para,1);isq=zeros(para,1);isi=isi+paradata2((1:para),1+count2);isq=isq+paradata2((1:para),2+count2);iout((1:para),jj)=isi;qout((1:para),jj)=isq;count2=count2+ml;end%********************end of file***************************%viterbi.m%viterbi解码程序function[decoder_output,survivor_state,cumulated_metric]=viterbi(G,k,channel_output) %[decoder_output,survivor_state,cumulated_metric]=viterbi(G,k,channel_output)%其中G是一个n行L*k列矩阵,它的每一行决定了从移位寄存器到输入码字的连接方式.%survivor_state是一个矩阵,它显示了通过网格的最优路径,这个矩阵通过一个单独%的函数metric(x,y)给出。

基于MATLAB的OFMD仿真实验-OFDM系统设计1

基于MATLAB的OFMD仿真实验-OFDM系统设计1

GI, TG (frac of TU)
24.6%
SubC 1K/2K
spacing/Hz
(子载波间隔)
4K/8K
1⁄4, 1⁄32
​1⁄8,
​1⁄16,

1⁄4, 1⁄32
​1⁄8,
​1⁄16,

1⁄4,
​1⁄6,
​1⁄9
4, 464 1, 116
4,464, 2,232, 1,116
2,000
1/128, 1/32, 1/16, 19/256, 1/8, 19/128, 1/4.
(CFO):
f
f
tx c
f
rx c
Doppler Shift (多普勒偏移)
CFO Estimation & Compensation
(先估计出偏移然后补偿,然后就可以消除频偏CFO实现同步)
Time/Frequency Synchronization
Find the start point of OFDM symbols (ISI free) CFO Estimation & Compensation (ICI free)
Noise Figure
SNR -- Signal to Noise Ratio -- 信噪比
Tx/Rx process of OFDM system
Time Synchronization
(时间同步)
Inter-symbol Interference (ISI)
N
N
N
Find the start point of OFDM symbols
Physical Layer System Design

mimoofdm无线通信技术与matlab代码

mimoofdm无线通信技术与matlab代码

mimoofdm无线通信技术与matlab代码1. 引言1.1 概述无线通信技术的发展迅猛,随着移动互联网时代的到来,人们对高速、稳定的无线通信需求日益增加。

MIMO-OFDM无线通信技术作为一种重要的解决方案,在提升系统容量和抗干扰性能方面具有显著优势。

本文旨在介绍MIMO-OFDM 无线通信技术原理,并借助MATLAB代码实现,通过仿真和性能评估分析展示其有效性和优越性。

1.2 文章结构本文分为五个部分:引言、MIMO-OFDM无线通信技术、MATLAB代码实现、实验结果与讨论以及结论与展望。

在引言部分,我们将简要介绍文章的背景和目标。

接下来,会详细讲解MIMO-OFDM无线通信技术的基本原理,并说明其在提高系统容量和抗干扰性能方面的作用。

然后,我们会详细描述如何使用MATLAB编写MIMO-OFDM系统模拟代码,并进行性能评估与分析。

随后,我们会展示仿真参数设置和结果展示,并对结果进行深入分析和性能讨论。

最后,在结论与展望部分,我们将总结本文的研究工作和贡献,并讨论目前的不足之处以及可能的改进方案。

1.3 目的本文的主要目的是深入介绍MIMO-OFDM无线通信技术及其原理,并通过MATLAB代码实现来验证其性能。

通过对实验结果进行分析和讨论,我们旨在揭示MIMO-OFDM技术在提高系统容量和抗干扰性能方面的优势。

同时,本文也希望为读者提供一个了解和学习MIMO-OFDM无线通信技术以及使用MATLAB进行系统模拟的参考。

以上就是“1. 引言”部分内容,概述了本文的背景、目标和结构。

在接下来的章节中,我们将逐一展开讲解MIMO-OFDM无线通信技术、MATLAB代码实现、实验结果与讨论以及结论与展望部分。

2. MIMO-OFDM无线通信技术:2.1 MIMO技术介绍:多输入多输出(MIMO)技术是一种通过在发射和接收端使用多个天线来增加系统容量和提高通信质量的无线通信技术。

MIMO技术利用空间上的多样性,通过在不同天线之间形成独立的传输通道,从而带来更好的抗干扰能力和信号接收品质。

ofdm解调matlab代码

ofdm解调matlab代码
在Matlab中实现OFDM解调的基本代码如下所示:
%假设接收到的信号为receivedSignal,其长度为N
N = length(receivedSignal);
%假设使用的子载波数量为M
Hale Waihona Puke M = 64;%生成一个长度为M的IFFT矩阵
IFFTMatrix = ifft(ones(1, M), M);
%对接收到的信号进行解调
demodulatedSignal = IFFTMatrix * receivedSignal;
%输出解调后的信号
disp(demodulatedSignal);
这个代码实现了基本的OFDM解调过程,即将接收到的信号通过一个逆快速傅里叶变换(IFFT)矩阵解调为原始数据信号。需要注意的是,这只是一个基本的示例,实际的OFDM解调过程可能需要进行同步、信道估计和均衡等操作。此外,对于不同的系统参数(如子载波数量、调制方式等),IFFT矩阵的大小和生成方式也可能不同。

基于MATLAB实现OFDM的解码

基于MATLAB实现OFDM的解码

毕业论文题目基于MATLAB的OFDM研究2019年 4 月基于MATLAB的OFDM研究摘要自80年代,数字移动通信技术逐渐开始成熟,并开始应用在各式各样的,种类不同的无线通信系统,例如,数字集群电话,数字蜂窝电话,无线寻呼等,以上使用的是特高频/甚高频波段的数字移动通信。

但是这两者的移动信道存在很多问题,噪声干扰,在多径传播时易造成码间串扰,选择性衰弱等。

为解决这些问题,OFDM出现了,即正交频分复用。

它是第四代移动通信的关键技术。

因为它的信道被利用率非常高,抗衰弱能力非常好。

OFDM的信号产生与解调的过程就是 IDFT/DFT 的变换过程。

正交频分复用(OFDM)是一种调制技术,在许多新兴的宽带无线和有线通信系统中得到了广泛应用。

由于OFDM技术具有利用多个频谱重叠的低速副载波传输高速数据流的能力,因此它具有频谱效率高、抗载波间和符号间抗干扰性、对服务器信道条件的适应性等优点,近年来,OFDM技术的研究越来越深入。

基于OFDM传输技术,被认为是未来超高速光传输的一种有前途的技术。

它可以构建一种在频谱分配和数据速率调节方面具有极大灵活性和可扩展性的新型弹性光网络结构,以支持未来多种业务和互联网流量的快速增长。

正交频分复用(OFDM)主要是针对多径接收的效果,通过将宽带频率选择性衰落信道许多狭窄的扁平子通道。

正交频分复用适应时变信道的灵活性采用各参数的条件副载波准确。

为了避免ISI多径,连续的OFDM符号被分开通过防护带。

这使得OFDM系统抗多径效应的思想利用FDM进行并行数据传输。

对OFDM的关注在无线和有线通信系统领域。

关键字:正道频分复用、OFDM、调制方式Decoding of OFDM System Based on MATLABAbstractSince the 1980s, digital mobile communication technology has gradually matured, and began to be applied in a variety of different types of wireless communication systems, such as digital trunking telephone, digital cellular phone, wireless paging, etc. The above uses digital mobile communication in UHF/VHF band. However, there are many problems in both mobile channels, such as noise interference, intersymbol interference and selective fading in multipath propagation. In order to solve these problems, the key technologies of the fourth generation mobile communication technology have emerged. It is better and more efficient, namely (orthogonal frequency division multiplexing) OFDM. It not only has high channel utilization, but also has good anti-fading ability. The process of signal generation and demodulation in OFDM is the transformation process of IDFT/DFT. Orthogonal Frequency Division Multiplexing (OFDM) is a modulation technology, which has been widely used in many emerging broadband wireless and wired communication systems. Because OFDM technology has the ability to transmit high-speed data streams using low-speed subcarriers with overlapping spectrum, it has the advantages of high spectral efficiency, anti-interference between carriers and symbols, and adaptability to server channel conditions. In recent years, the research of OFDM technology has become more and more in-depth. Based on OFDM transmission technology, it is considered as a promising technology for ultra-high-speed optical transmission in the future. It can construct a new elastic optical network structure with great flexibility and scalability in spectrum allocation and data rate regulation to support the rapid growth of various services and Internet traffic in the future.Orthogonal Frequency Division Multiplexing (OFDM) is mainly aimed at the effect of multipath reception. It uses many narrowflat subchannels in broadband frequency selective fading channels. Orthogonal Frequency Division Multiplexing (OFDM) is flexible to adapt to time-varying channels, and the subcarriers with different parameters are accurate. To avoid ISI multipath, consecutive OFDM symbols are separated through the guard belt. This makes the idea of anti-multipath effect in OFDM system use FDM to carry out parallel data transmission. Concern about OFDM is in the field of wireless and wired communication systems.Key words: channel frequency division multiplexing, OFDM目录摘要 (Ⅰ)Abstract (Ⅱ)第一章绪论 (1)1.1 OFDM的研究背景、意义 (1)1.2 OFDM的发展 (1)1.3 OFDM的主要优点和缺点 (1)1.4 OFDM的应用 (2)第二章OFDM基本原理 (4)2.1 原理、数学描述 (4)2.2 OFDM的参数、特性 (5)2.3 子载波调制 (6)第三章OFDM的系统仿真 (9)3.1 MATLAB的特点和功能 (9)3.2 OFDM系统仿真 (9)3.2.1 OFDM时域波形 (9)3.2.2 OFDM子载波频谱 (10)3.2.3 QPSK调制 (11)3.2.4 QPSK调制星座图 (13)3.2.5 并串转换 (13)3.2.6 QPSK解调 (14)3.2.7 接收信号 (15)3.2.8 OFDM解码实现 (15)结束语 (20)参考文献 (21)致谢 (23)第一章绪论1.1 OFDM的研究背景、意义正交频分复用(OFDM)已成为世界上许多电信标准的基础(包括无线局域网(LAN)、数字地面电视(DTT)、数字无线电广播)。

ofdm子载波频谱matlab代码

ofdm子载波频谱matlab代码

ofdm子载波频谱matlab代码以下是一个简单的OFDM子载波频谱的Matlab代码示例。

该代码主要生成一个OFDM信号,并计算其频谱。

```Matlab% 参数设定N = 64; % 子载波数CP = N/4; % 循环前缀长度t = 1/20e3; % 时间长度Ts = t/N; % 符号周期f0 = 2.5e9; % 载波频率fc = 10*f0; % 信号带宽Tb = N*Ts; % 比特周期c = 3e8; % 光速d = c*Ts/2; % 发送天线与接收天线间距SNRdB = 10; % 比特能量噪声比(dB)snr = SNRdB/10; % 比特能量噪声比EbN0 = 10^(snr/10); % 比特能量噪声密度比EbN0_dB = 10*log10(EbN0); % 比特能量噪声密度比(dB)Pn = 1/sqrt(2)*(sqrt(2)*sqrt(pi)*sqrt(EbN0)*1i)/2; % 加性高斯白噪声功率谱密度Pn_dB = 10*log10(Pn); % 加性高斯白噪声功率谱密度(dB)% 生成OFDM信号data = randi([0,1],N,1); % 生成随机的二进制数据data_fft = fft(data); % FFT变换data_fft_cp = [data_fft, zeros(CP,1)]; % 添加循环前缀x = exp(1i*2*pi*f0*(0:N-1)*Ts); % 生成载波信号x_cp = [x, zeros(CP,1)]; % 添加循环前缀x_cp_data = x_cp.*data_fft_cp; % 调制信号x_cp_data_mod = real(x_cp_data); % 取实部,得到复数调制信号x_cp_data_mod_tx = repmat(x_cp_data_mod,1,d); % 发送天线复制信号x_cp_data_mod_rx = repmat(x_cp_data_mod,1,d); % 接收天线复制信号x_cp_data_mod_rx(:,:) = conj(x_cp_data_mod(:,:)); % 天线相位翻转,实现模拟MIMO传输y = filter([1-d -d],1,x_cp_data_mod_tx) + filter([-d -d 1],1,x_cp_data_mod_rx); % MIMO接收信号滤波器处理y = y/2; % 均衡处理,实现模拟解调y_fft = fft(y); % FFT变换,解调信号y_fft = y_fft(CP+1:end); % 去掉循环前缀,得到解调数据频域信号y = real(y_fft); % 取实部,得到解调数据时域信号y = ifft(y); % IFFT变换,得到解调数据时域信号data_demod = real(y); % 取实部,得到解调数据时域信号% 计算频谱frequencies = -fc:fc/(N*Ts); % 频率轴取值范围power = abs(fft(data))**2; % 计算功率谱密度函数power_noise = abs(fft(randn(N,length(t)))**2); % 计算加性高斯白噪声功率谱密度函数power = power + power_noise; % 计算总功率谱密度函数power = power/max(power); % 归一化处理,使最大功率为1figure; plot(frequencies,power); xlabel('Frequency (Hz)'); ylabel('Power Spectral Density (W/Hz)'); title('Power Spectrum'); grid on;以上就是关于ofdm子载波频谱matlab代码的介绍,欢迎补充。

基于Matlab的OFDM同步算法

基于Matlab的OFDM同步算法

02
OFDM技术通过将高速数据流分散到多个子载波上,增加信号传输的可靠性, 同时通过添加循环前缀,有效抵抗多径干扰。
03
同步技术则关注如何快速、准确地找到接收信号的起始位置,以恢复原始数据 。
算法流程
编码阶段,发送端将输入数据进行OFDM编码,添加循 环前缀和其他必要的标识。
解调阶段,接收端对接收到的OFDM信号进行解码,提 取出原始数据。
时频跟踪
展示算法在时变信道下的跟踪性能,验证其 适应能力。
误码率分析
通过分析误码率等指标,验证算法在实际应 用中的可靠性。
复杂度评估
对优化前后的算法复杂度进行评估,展示优 化在降低运算复杂度方面的效果。
05
总结与展望
研究成果总结
高效的算法
基于matlab的ofdm同步算法在仿真实验中表现出高效性 ,能够快速准确地实现信号同步。
01
预处理接收信号
通过去除噪声、频偏等手段,提 高接收信号的质量。
构建解调器
根据估计的参数,构建适合的解 调器对OFDM信号进行解调。
03
02
估计时频参数
利用训练序列或已知信息,估计 出信号的时域和频域参数。
优化解调结果
对解调后的信号进行进一步优化 ,如去除干扰、均衡等。
04
优化结果展示
性能对比
将优化后的算法与传统的OFDM同步算法进 行性能对比,展示优化的有效性。
2. 生成训练序列:在每 个OFDM符号前添加一 个特定的训练序列,用
于接收端进行同步。
实现步骤
3. 调制
对输入数据进行QPSK或QAM等调制。
4. IFFT
进行逆快速傅里叶变换(IFFT),将频域数据转换为时域数据。
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
figure(2);
plot(complex_carrier_matrix,'*r');%16QAM调制后星座图
title('16QAM调制后星座图')
axis([-4, 4, -4, 4]);
grid on
%==========分配载波到指定的IFFT位置==========================
clc;
clear all;
close all;
fprintf('OFDM系统仿真\n');
carrier_count=input('输入系统仿真的子载波数: \n');%子载波数128,64,32,16
symbols_per_carrier=30;%每子载波含符号数
bits_per_symbol=4;%每符号含比特数,16QAM调制
end
figure(7);
plot(0:IFFT_bin_length-1+GI+GIP,windowed_time_wave_matrix_cp(2,:));
axis([0, 700, -0.2, 0.2]);
grid on;
ylabel('振幅');
xlabel('时间');
title('加窗之后OFDM信号的波形');
%==============16QAM调制====================================
complex_carrier_matrix=qam16(baseband_out);%列向量
complex_carrier_matrix=reshape(complex_carrier_matrix',carrier_count,symbols_per_carrier)';%串并转换,转换为symbols_per_carrier*carrier_count矩阵
IFFT_bin_length=1024;%FFT点数
PrefixRatio=1/4;%保护间隔与OFDM数据的比例1/6~1/4
GI=PrefixRatio*IFFT_bin_length ;%每一个OFDM符号添加的循环前缀长度为1/4*IFFT_bin_length ,即256
beta=1/32;%窗函数滚降系数
XX=zeros(symbols_per_carrier,IFFT_bin_length+GI+GIP);
for k=1:symbols_per_carrier;
for i=1:IFFT_bin_length;
XX(k,i+GI)=signal_after_IFFT(k,i);
end
for i=1:GI;
XX(k,i)=signal_after_IFFT(k,i+IFFT_bin_length-GI);%添加循环前缀
end
for j=1:GIP;
XX(k,IFFT_bin_length+GI+j)=signal_after_IFFT(k,j);%添加循环后缀
end
end
time_wave_matrix_cp=XX;%添加了循环前缀与后缀的时域信号矩阵,此时一个OFDM符号长度为IFFT_bin_length+GI+GIP
for i = 1:symbols_per_carrier-1 ;
windowed_Tx_data((IFFT_bin_length+GI)*i+1:(IFFT_bin_length+GI)*(i+1)+GIP)=windowed_time_wave_matrix_cp(i+1,:);%循环后缀与循环前缀相叠加
title('OFDM载波相位谱')
%========通过IFFT将频域转化为时域,得到时域信号===============
signal_after_IFFT=ifft(IFFT_modulation,IFFT_bin_length,2);%OFDM调制即IFFT time_wave_matrix =signal_after_IFFT;%时域波形矩阵,行为每载波所含符号数,列ITTF点数,子载波映射在其内,每一行即为一个OFDM符号
Tx_data=reshape(windowed_time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI+GIP),1)';%加窗后,循环前缀与后缀不叠加的串行信号
temp_time1 = (symbols_per_carrier)*(IFFT_bin_length+GI+GIP);%加窗后循环前缀与后缀不叠加发送总位数
grid on
ylabel('振幅'); xlabel('时间');
title('循环前后缀叠加的OFDM信号')
%=================未加窗发送信号频谱=========================
symbols_per_average = ceil(symbols_per_carrier/5);
%==============OFDM符号加窗======================
windowed_time_wave_matrix_cp=zeros(1,IFFT_bin_length+GI+GIP);
for i = 1:symbols_per_carrier
windowed_time_wave_matrix_cp(i,:) = real(time_wave_matrix_cp(i,:)).*rcoswindow(beta,IFFT_bin_length+GI)';%加窗升余弦窗
GIP=beta*(IFFT_bin_length+GI);%循环后缀的长度40
SNR=10; %信噪比dB
%================信号产生===================================
baseband_out_length=carrier_count*symbols_per_carrier*bits_per_symbol;%所输入的比特数目
temp_time2 =symbols_per_carrier*(IFFT_bin_length+GI)+GIP;
subplot(2,1,2);
plot(0:temp_time2-1,windowed_Tx_data);%循环后缀与循环前缀相叠加发送信号波形
axis([0, 8000, -0.4, 0.4]);
end
average_fft_log = 20*log10(average_fft);
figure (9)
subplot(2,1,1);
plot((0:(avg_temp_time-1))/avg_temp_time, average_fft_log)
hold on
plot(0:1/IFFT_bin_length:1, -35, 'rd')
subset_ofdm= Tx_data_withoutwindow (((a*avg_temp_time)+1):((a+1)*avg_temp_time
)); subset_ofdm_f = abs(fft(subset_ofdm));
average_fft = average_fft + (subset_ofdm_f/averages);
avg_temp_time = (IFFT_bin_length+GI+GIP)*symbols_per_average;
averages = floor(temp_time1/avg_temp_time);
average_fft(1:avg_temp_time) = 0;
for a = 0:(averages-1)
figure(6);
plot(0:length(time_wave_matrix_cp)-1,time_wave_matrix_cp(2,:));
axis([0, 700, -0.2, 0.2]);
grid on;
ylabel('振幅');
xlabel('时间');
title('加入循环前缀后缀的OFDM波形');
IFFT_modulation=zeros(symbols_per_carrier,IFFT_bin_length);%添0组成IFFT运算
IFFT_modulation(:,carriers ) = complex_carrier_matrix ;%未添加导频信号,子载波映射在此处
IFFT_modulation(:,conjugate_carriers) =conj(complex_carrier_matrix);%共轭复数映射
end
%=======================并串转换=========================
Tx_data_withoutwindow=reshape(time_wave_matrix_cp',(symbols_per_carrier)*(IFFT_bin_length+GI+GIP),1)'; %不加窗,循环前缀与后缀不叠加的串行信号
figure(5);
plot(0:IFFT_bin_length-1,time_wave_matrix(2,:));
axis([0, 700, -0.2, 0.2]);
相关文档
最新文档