【MIMO通信】基于matlab空时分组编码MIMO_OFDM通信系统仿真【含Matlab源码 663期】
【摘要】
一、获取代码方式
获取代码方式1: 完整代码已上传我的资源:【MIMO通信】基于matlab空时分组编码MIMO_OFDM通信系统仿真【含Matlab源码 663期】
获取代码方式2: 通过订阅紫极神...
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【MIMO通信】基于matlab空时分组编码MIMO_OFDM通信系统仿真【含Matlab源码 663期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得2份代码(有效期为订阅日起,三天内有效);
二、MIMO_OFDM通信系统简介
理论知识参考文献:基于MATLAB/GUI的MIMO通信仿真软件设计与实现
三、部分源代码
%main_STBC_MIMO_OFDM.m
%这是一个基于空时分组编码的MIMO_OFDM通信系统的仿真设计。
%此系统包括QPSK调制解调,IFFT调制,空时编解码,基于训
%练符号的信道估计等通信模块。
clear all
close all
clc
%+++++++++++++++++++++++++++变量++++++++++++++++++++++++++++++
i=sqrt(-1);
IFFT_bin_length=512; %傅立叶变换抽样点数目
carrier_count=100; %子载波数目
symbols_per_carrier=66; %符号数/载波
cp_length=10; %循环前缀长度
addprefix_length=IFFT_bin_length+cp_length;
M_psk=4;
bits_per_symbol=log2(M_psk); %位数/符号
%[x1 x2;-x2* x1*] 二天线发送矩阵
% O=[1 2;-2+j 1+j];
%[x1 -x2 -x3;x2* x1* 0;x3* 0 x1*;0 -x3* x2*] 三天线发送矩阵
O=[1 -2 -3;2+j 1+j 0;3+j 0 1+j;0 -3+j 2+j];
co_time=size(O,1);
Nt=size(O,2); %发射天线数目
Nr=2; %接收天线数目
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%+++++++++++++++++++++++++++发射机++++++++++++++++++++++++++++++
disp('--------------start-------------------');
num_X=1;
for cc_ro=1:co_time
for cc_co=1:Nt
num_X=max(num_X,abs(real(O(cc_ro,cc_co))));
end
end
co_x=zeros(num_X,1);
for con_ro=1:co_time
for con_co=1:Nt %用于确定矩阵“O”中元素的位置,符号以及共轭情况
if abs(real(O(con_ro,con_co)))~=0
delta(con_ro,abs(real(O(con_ro,con_co))))=sign(real(O(con_ro,con_co)));
epsilon(con_ro,abs(real(O(con_ro,con_co))))=con_co;
co_x(abs(real(O(con_ro,con_co))),1)=co_x(abs(real(O(con_ro,con_co))),1)+1;
eta(abs(real(O(con_ro,con_co))),co_x(abs(real(O(con_ro,con_co))),1))=con_ro;
coj_mt(con_ro,abs(real(O(con_ro,con_co))))=imag(O(con_ro,con_co));
end
end
end
eta=eta.';
eta=sort(eta);
eta=eta.';
% 坐标: (1 to 100) + 14=(15:114)
carriers = (1: carrier_count) + (floor(IFFT_bin_length/4) - floor(carrier_count/2));
% 坐标 :256 - (15:114) + 1= 257 - (15:114) = (242:143)
conjugate_carriers=IFFT_bin_length-carriers+2;
tx_training_symbols=training_symbol(Nt,carrier_count);
baseband_out_length = carrier_count * symbols_per_carrier;
snr_min=3; %最小信噪比
snr_max=15; %最大信噪比
graph_inf_bit=zeros(snr_max-snr_min+1,2,Nr); %绘图信息存储矩阵
graph_inf_sym=zeros(snr_max-snr_min+1,2,Nr);
for SNR=snr_min:snr_max
clc
disp('Wait until SNR=');disp(snr_max);
SNR
n_err_sym=zeros(1,Nr);
n_err_bit=zeros(1,Nr);
Perr_sym=zeros(1,Nr);
Perr_bit=zeros(1,Nr);
re_met_sym_buf=zeros(carrier_count,symbols_per_carrier,Nr);
re_met_bit=zeros(baseband_out_length,bits_per_symbol,Nr);
%生成随机数用于仿真
baseband_out=round(rand(baseband_out_length,bits_per_symbol));
%二进制向十进制转换
de_data=bi2de(baseband_out);
%PSK调制
data_buf=pskmod(de_data,M_psk,0);
carrier_matrix=reshape(data_buf,carrier_count,symbols_per_carrier);
%取数为空时编码做准备,此处每次取每个子载波上连续的两个数
for tt=1:Nt:symbols_per_carrier
data=[];
for ii=1:Nt
tx_buf_buf=carrier_matrix(:,tt+ii-1);
data=[data;tx_buf_buf];
end
XX=zeros(co_time*carrier_count,Nt);
for con_r=1:co_time %进行空时编码
for con_c=1:Nt
if abs(real(O(con_r,con_c)))~=0
if imag(O(con_r,con_c))==0
XX((con_r-1)*carrier_count+1:con_r*carrier_count,con_c)=data((abs(real(O(con_r,con_c)))-1)*carrier_count+1:abs(real(O(con_r,con_c)))...
*carrier_count,1)*sign(real(O(con_r,con_c)));
else
XX((con_r-1)*carrier_count+1:con_r*carrier_count,con_c)=conj(data((abs(real(O(con_r,con_c)))-1)*carrier_count+1:abs(real(O(con_r,con_c)))...
*carrier_count,1))*sign(real(O(con_r,con_c)));
end
end
end
end %空时编码结束
XX=[tx_training_symbols;XX]; %添加训练序列
rx_buf=zeros(1,addprefix_length*(co_time+1),Nr);
for rev=1:Nr
for ii=1:Nt
tx_buf=reshape(XX(:,ii),carrier_count,co_time+1);
IFFT_tx_buf=zeros(IFFT_bin_length,co_time+1);
IFFT_tx_buf(carriers,:)=tx_buf(1:carrier_count,:);
IFFT_tx_buf(conjugate_carriers,:)=conj(tx_buf(1:carrier_count,:));
time_matrix=ifft(IFFT_tx_buf);
time_matrix=[time_matrix((IFFT_bin_length-cp_length+1):IFFT_bin_length,:);time_matrix];
tx=time_matrix(:)';
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%+++++++++++++++++++++++++++信道++++++++++++++++++++++++++++++
%d=randint(1,4,[1,7]); %4多经信道模拟
%a=randint(1,4,[2,7])/10;
tx_tmp=tx;
d=[4,5,6,2;4,5,6,2;4,5,6,2;4,5,6,2];
a=[0.2,0.3,0.4,0.5;0.2,0.3,0.4,0.5;0.2,0.3,0.4,0.5;0.2,0.3,0.4,0.5];
for jj=1:size(d,2)
copy=zeros(size(tx)) ;
for kk = 1 + d(ii,jj): length(tx)
copy(kk) = a(ii,jj)*tx(kk - d(ii,jj)) ;
end
tx_tmp=tx_tmp+copy;
end
txch=awgn(tx_tmp,SNR,'measured'); %添加高斯白噪声
rx_buf(1,:,rev)=rx_buf(1,:,rev)+txch;
end
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%+++++++++++++++++++++++++++接收机++++++++++++++++++++++++++++++
rx_spectrum=reshape(rx_buf(1,:,rev),addprefix_length,co_time+1);
rx_spectrum=rx_spectrum(cp_length+1:addprefix_length,:);
FFT_tx_buf=zeros(IFFT_bin_length,co_time+1);
FFT_tx_buf=fft(rx_spectrum);
spectrum_matrix=FFT_tx_buf(carriers,:);
Y_buf=(spectrum_matrix(:,2:co_time+1));
Y_buf=conj(Y_buf');
spectrum_matrix1=spectrum_matrix(:,1);
Wk=exp((-2*pi/carrier_count)*i);
L=10;
p=zeros(L*Nt,1);
for jj=1:Nt
for l=0:L-1
for kk=0:carrier_count-1
p(l+(jj-1)*L+1,1)=p(l+(jj-1)*L+1,1)+spectrum_matrix1(kk+1,1)*conj(tx_training_symbols(kk+1,jj))*Wk^(-(kk*l));
end
end
end
%q=zeros(L*Nt,L*Nt);
%for ii=1:Nt
% for jj=1:Nt
% for l1=0:L-1
% for l2=0:L-1
% for kk=0:carrier_count-1
% q(l2+(ii-1)*L+1,l1+(jj-1)*L+1)= q(l2+(ii-1)*L+1,l1+(jj-1)*L+1)+tx_training_symbols(kk+1,ii)*conj(tx_training_symbols(kk+1,jj))*Wk^(-(kk*(-l1+l2)));
% end
% end
% end
% end
%end
%h=inv(q)*p;
h=p/carrier_count;
H_buf=zeros(carrier_count,Nt);
for ii=1:Nt
for kk=0:carrier_count-1
for l=0:L-1
H_buf(kk+1,ii)=H_buf(kk+1,ii)+h(l+(ii-1)*L+1,1)*Wk^(kk*l);
end
end
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/115362336
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)