bpskmatlab代码(bpsk调制及解调matlab)
admin 发布:2022-12-19 19:33 148
今天给各位分享bpskmatlab代码的知识,其中也会对bpsk调制及解调matlab进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、Matlab编写BPSK信号通过AWGN信道的仿真过程
- 2、用matlab进行BPSK调制和解调的仿真
- 3、几个问题关于Matlab编写BPSK信号通过AWGN信道的仿真(在线跪求大神,不胜感激)!!!
- 4、matlab编程实现最大似然解调 采用BPSK调制 并画出误码率曲线
- 5、matlab高手请支援
Matlab编写BPSK信号通过AWGN信道的仿真过程
主程序部分:
%programm 3-1
%bpsk.m
%
% Simulation program to realize BPSK transmission system
%
% Programmed by H.Harada and T.Yamamura,
%
%******************** Preparation part **********************
sr=256000.0; % Symbol rate
ml=1; % Number of modulation levels
br=sr.*ml; % Bit rate (=symbol rate in this case)
nd = 1000; % Number of symbols that simulates in each loop
ebn0=3; % Eb/N0
IPOINT=8; % Number of oversamples
%******************* Filter initialization ********************
irfn=21; % Number of filter taps
alfs=0.5; % Rolloff factor
[xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); %Transmitter filter coefficients
[xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); %Receiver filter coefficients
%******************** START CALCULATION *********************
nloop=100; % Number of simulation loops
noe = 0; % Number of error data
nod = 0; % Number of transmitted data
for iii=1:nloop
%******************** Data generation ***********************
data=rand(1,nd)0.5; % rand: built in function
%******************** BPSK Modulation ***********************
data1=data.*2-1;
data2 = oversamp( data1, nd , IPOINT) ;
data3 = conv(data2,xh); % conv: built in function
%****************** Attenuation Calculation *****************
spow=sum(data3.*data3)/nd;
attn=0.5*spow*sr/br*10.^(-ebn0/10);
attn=sqrt(attn);
%********************** Fading channel **********************
% Generated data are fed into a fading simulator
% In the case of BPSK, only Ich data are fed into fading counter
% [ifade,qfade]=sefade(data3,zeros(1,length(data3)),itau,dlvl,th1,n0,itnd1,now1,length(data3),tstp,fd,flat);
% Updata fading counter
%itnd1 = itnd1+ itnd0;
%************ Add White Gaussian Noise (AWGN) ***************
inoise=randn(1,length(data3)).*attn; % randn: built in function
data4=data3+inoise;
data5=conv(data4,xh2); % conv: built in function
sample=irfn*IPOINT+1;
data6 = data5(sample:8:8*nd+sample-1);
%******************** BPSK Demodulation *********************
demodata=data6 0;
%******************** Bit Error Rate (BER) ******************
noe2=sum(abs(data-demodata)); % sum: built in function
nod2=length(data); % length: built in function
noe=noe+noe2;
nod=nod+nod2;
fprintf('%d\t%e\n',iii,noe2/nod2); %fprintf:built in function
end % for iii=1:nloop
%********************** Output result ***********************
ber = noe/nod;
fprintf('%d\t%d\t%d\t%e\n',ebn0,noe,nod,noe/nod);
%******************** end of file ***************************
下面是子程序:
% Program 3-2
% oversamp.m
%
% Insert zero data to input data
%
% Programmed by H.Harada
%
function [out] = oversamp( indata, nsymb , sample)
%****************** variables *************************
% indata : input sequence
% nsymb : Number of symbols
% sample : Number of oversample
% *****************************************************
out=zeros(1,nsymb*sample);
out(1:sample:1+sample*(nsymb-1))=indata;
%******************** end of file ***************************
子程序:
% Program 3-3
% hrollfcoef.m
%
% Generate coefficients of Nyquist filter
%
% programmed by H.Harada
%
function [xh] = hrollfcoef(irfn,ipoint,sr,alfs,ncc)
%****************** variables *************************
% irfn : Number of symbols to use filtering
% ipoint : Number of samples in one symbol
% sr : symbol rate
% alfs : rolloff coeficiense
% ncc : 1 -- transmitting filter 0 -- receiving filter
% *****************************************************
xi=zeros(1,irfn*ipoint+1);
xq=zeros(1,irfn*ipoint+1);
point = ipoint;
tr = sr ;
tstp = 1.0 ./ tr ./ ipoint;
n = ipoint .* irfn;
mid = ( n ./ 2 ) + 1;
sub1 = 4.0 .* alfs .* tr; % 4*alpha*R_s
for i = 1 : n
icon = i - mid;
ym = icon;
if icon == 0.0
xt = (1.0-alfs+4.0.*alfs./pi).* tr; % h(0)
else
sub2 =16.0.*alfs.*alfs.*ym.*ym./ipoint./ipoint;
if sub2 ~= 1.0
x1=sin(pi*(1.0-alfs)/ipoint*ym)./pi./(1.0-sub2)./ym./tstp;
x2=cos(pi*(1.0+alfs)/ipoint*ym)./pi.*sub1./(1.0-sub2);
xt = x1 + x2; % h(t) plot((1:length(xh)),xh)
else % (4alphaRst)^2 = 1plot((1:length(xh)),xh)
xt = alfs.*tr.*((1.0-2.0/pi).*cos(pi/4.0/alfs)+(1.0+2.0./pi).*sin(pi/4.0/alfs))./sqrt(2.0);
end % if sub2 ~= 1.0
end % if icon == 0.0
if ncc == 0 % in the case of receiver
xh( i ) = xt ./ ipoint ./ tr; % normalization
elseif ncc == 1 % in the case of transmitter
xh( i ) = xt ./ tr; % normalization
else
error('ncc error');
end % if ncc == 0
end % for i = 1 : n
%******************** end of file ***************************
就是这三个了,不知道能不能帮助你、、、
用matlab进行BPSK调制和解调的仿真
function output_frame = demodulation(input_modu, index)
% demodulation for IEEE802.11a
% Input: input_modu, complex values representing constellation points
% index
% Output: output_frame, output bit stream (data unit is one bit)
% In this version, increase the quatilization levels into 8.
% note: Matlab index starts from 1
Q_length=length(input_modu);
QAM_input_I = real(input_modu);
QAM_input_Q = imag(input_modu);
output_frame = zeros(1,length(input_modu)*index);
switch index
case 1,
BPSK_Demodu_I = [0 1]; %f(m)=(m+1)/2 + 1, so I=-1 --- 1, I=1 --- 2
idx = find(QAM_input_I1);
QAM_input_I(idx) = 1;
idx = find(QAM_input_I-1);
QAM_input_I(idx) = -1;
output_frame = BPSK_Demodu_I(round((QAM_input_I+1)/2) + 1);
case 2,
QPSK_Demodu_IQ = [0 1]; %f(m)=(m+1)/2 + 1, so I=-1 --- 1, I=1 --- 2
idx = find(QAM_input_I1);
QAM_input_I(idx) = 1;
idx = find(QAM_input_I-1);
QAM_input_I(idx) = -1;
idx = find(QAM_input_Q1);
QAM_input_Q(idx) = 1;
idx = find(QAM_input_Q-1);
QAM_input_Q(idx) = -1;
output_frame(1:2:end) = QPSK_Demodu_IQ(round((QAM_input_I+1)/2) + 1);
output_frame(2:2:end) = QPSK_Demodu_IQ(round((QAM_input_Q+1)/2) + 1);
case 3,
remapping=[0 0 0;0 0 1;0 1 0;0 1 1;1 0 0;1 0 1;1 1 0;1 1 1].';
for i=1:Q_length
phase_det=[2QAM_input_I(i)0QAM_input_Q(i) 0QAM_input_I(i)QAM_input_I(i)20QAM_input_Q(i) QAM_input_I(i)-20QAM_input_Q(i) -2QAM_input_I(i)QAM_input_I(i)00QAM_input_Q(i) QAM_input_I(i)-2QAM_input_Q(i)0 QAM_input_I(i)0-2QAM_input_I(i)QAM_input_Q(i)0 2QAM_input_I(i)QAM_input_Q(i)0 0QAM_input_I(i)QAM_input_I(i)2QAM_input_Q(i)0]
a=find(phase_det);
output_frame((1+(i-1)*3):(3+(i-1)*3))=remapping((1+(a-1)*3):(3+(a-1)*3));
end
case 4,
QAM_16_Demodu_IQ = [0 1 3 2]; %f(m)=(m+3)/2 + 1, so I=-3 --- 1, I=1 --- 3
idx = find(QAM_input_I3);
QAM_input_I(idx) = 3;
idx = find(QAM_input_I-3);
QAM_input_I(idx) = -3;
idx = find(QAM_input_Q3);
QAM_input_Q(idx) = 3;
idx = find(QAM_input_Q-3);
QAM_input_Q(idx) = -3;
tmp = round((QAM_input_I+3)/2) + 1;
output_frame(1:4:end) = bitget(QAM_16_Demodu_IQ(tmp),2);
output_frame(2:4:end) = bitget(QAM_16_Demodu_IQ(tmp),1);
tmp = round((QAM_input_Q+3)/2) + 1;
output_frame(3:4:end) = bitget(QAM_16_Demodu_IQ(tmp),2);
output_frame(4:4:end) = bitget(QAM_16_Demodu_IQ(tmp),1);
case 5,
remapping=[0 0 0 0 0;0 0 0 0 1;0 0 0 1 0;0 0 0 1 1;0 0 1 0 0;0 0 1 0 1;0 0 1 1 0;0 0 1 1 1;
0 1 0 0 0;0 1 0 0 1;0 1 0 1 0;0 1 0 1 1;0 1 1 0 0;0 1 1 0 1;0 1 1 1 0;0 1 1 1 1;
1 0 0 0 0;1 0 0 0 1;1 0 0 1 0;1 0 0 1 1;1 0 1 0 0;1 0 1 0 1;1 0 1 1 0;1 0 1 1 1;
1 1 0 0 0;1 1 0 0 1;1 1 0 1 0;1 1 0 1 1;1 1 1 0 0;1 1 1 0 1;1 1 1 1 0;1 1 1 1 1].';
for i=1:Q_length
phase_det=[4QAM_input_I(i)0QAM_input_Q(i)QAM_input_Q(i)2;2QAM_input_I(i)QAM_input_I(i)40QAM_input_Q(i)QAM_input_Q(i)2;0QAM_input_I(i)QAM_input_I(i)20QAM_input_Q(i)QAM_input_Q(i)2;4QAM_input_I(i)2QAM_input_Q(i)QAM_input_Q(i)4;
2QAM_input_I(i)QAM_input_I(i)42QAM_input_Q(i)QAM_input_Q(i)4;0QAM_input_I(i)QAM_input_I(i)22QAM_input_Q(i)QAM_input_Q(i)4;2QAM_input_I(i)QAM_input_I(i)44QAM_input_Q(i);0QAM_input_I(i)QAM_input_I(i)24QAM_input_Q(i);
QAM_input_I(i)-40QAM_input_Q(i)QAM_input_Q(i)2;-4QAM_input_I(i)QAM_input_I(i)-20QAM_input_Q(i)QAM_input_Q(i)2;-2QAM_input_I(i)QAM_input_I(i)00QAM_input_Q(i)QAM_input_Q(i)2;QAM_input_I(i)-42QAM_input_Q(i)QAM_input_Q(i)4;
-4QAM_input_I(i)QAM_input_I(i)-22QAM_input_Q(i)QAM_input_Q(i)4;-2QAM_input_I(i)QAM_input_I(i)02QAM_input_Q(i)QAM_input_Q(i)4;-4QAM_input_I(i)QAM_input_I(i)-24QAM_input_Q(i);-2QAM_input_I(i)QAM_input_I(i)04QAM_input_Q(i);
QAM_input_I(i)-4-2QAM_input_Q(i)QAM_input_Q(i)0;-4QAM_input_I(i)QAM_input_I(i)-2-2QAM_input_Q(i)QAM_input_Q(i)0;-2QAM_input_I(i)QAM_input_I(i)00QAM_input_Q(i)QAM_input_Q(i)0;QAM_input_I(i)-4-4QAM_input_Q(i)QAM_input_Q(i)-2;
-4QAM_input_I(i)QAM_input_I(i)-2-4QAM_input_Q(i)QAM_input_Q(i)-2;-2QAM_input_I(i)QAM_input_I(i)0-4QAM_input_Q(i)QAM_input_Q(i)-2;-4QAM_input_I(i)QAM_input_I(i)-2QAM_input_Q(i)-4;-2QAM_input_I(i)QAM_input_I(i)0QAM_input_Q(i)-4;
4QAM_input_I(i)-2QAM_input_Q(i)QAM_input_Q(i)0;2QAM_input_I(i)QAM_input_I(i)4-2QAM_input_Q(i)QAM_input_Q(i)0;0QAM_input_I(i)QAM_input_I(i)20QAM_input_Q(i)QAM_input_Q(i)0;4QAM_input_I(i)-4QAM_input_Q(i)QAM_input_Q(i)-2;
2QAM_input_I(i)QAM_input_I(i)4-4QAM_input_Q(i)QAM_input_Q(i)-2;0QAM_input_I(i)QAM_input_I(i)2-4QAM_input_Q(i)QAM_input_Q(i)-2;2QAM_input_I(i)QAM_input_I(i)4QAM_input_Q(i)-4;0QAM_input_I(i)QAM_input_I(i)2QAM_input_Q(i)-4];
a=find(phase_det);
output_frame((1+(i-1)*5):(5+(i-1)*5))=remapping((1+(a-1)*5):(5+(a-1)*5));
end %5+i 3+i 1+i 5+3*i 3+3*i 1+3*i 3+5*i 1+5*i -5+i -3+i -1+i -5+3*i -3+3*i -1+3*i -3+5*i -1+5*i -5-i -3-i -1-i -5-3*i -3-3*i -1-3*i -3-5*i -1-5*i 5-i 3-i 1-i 5-3*i 3-3*i 1-3*i 3-5*i 1-5*i
case 6,
QAM_64_Demodu_IQ = [0 1 3 2 6 7 5 4]; %f(m)=(m+7)/2 + 1, so I=-7 --- 1, I=1 --- 5
idx = find(QAM_input_I7);
QAM_input_I(idx) = 7;
idx = find(QAM_input_I-7);
QAM_input_I(idx) = -7;
idx = find(QAM_input_Q7);
QAM_input_Q(idx) = 7;
idx = find(QAM_input_Q-7);
QAM_input_Q(idx) = -7;
tmp = round((QAM_input_I+7)/2) + 1;
output_frame(1:6:end) = bitget(QAM_64_Demodu_IQ(tmp),3);
output_frame(2:6:end) = bitget(QAM_64_Demodu_IQ(tmp),2);
output_frame(3:6:end) = bitget(QAM_64_Demodu_IQ(tmp),1);
tmp = round((QAM_input_Q+7)/2) + 1;
output_frame(4:6:end) = bitget(QAM_64_Demodu_IQ(tmp),3);
output_frame(5:6:end) = bitget(QAM_64_Demodu_IQ(tmp),2);
output_frame(6:6:end) = bitget(QAM_64_Demodu_IQ(tmp),1);
end
几个问题关于Matlab编写BPSK信号通过AWGN信道的仿真(在线跪求大神,不胜感激)!!!
求一份完整的Matlab编写BPSK信号通过AWGN信道仿真过程的程序。最好能有注释。在线求啊 主程序部分: %programm 3-1 %bpsk.m % % Simulation program
matlab编程实现最大似然解调 采用BPSK调制 并画出误码率曲线
您好,您这样:
clc;
clear;
fc=4800;fs=12000;fb=2400;
%要调制的数字信号
a=randint(1,12,2);%随机产生12个“0”,“1”
s=zeros(1,60);
for i=1:12
for j=1:5
if(a(i)==0)
s(j+(i-1)*5)=0;
else
s(j+(i-1)*5)=1;
end
end
end
plot(s);xlabel('基带信号');
figure
pwelch(s);%功率谱
figure
%波形成形滤波器(平方根升余弦滚降)
h=firrcos(14,1200,1200,4800,'sqrt');
figure
stem(h);xlabel('成形滤波器的单位冲击响应');
[H,W]=freqz(h,1);
H=abs(H);
figure
plot(H);xlabel('成形滤波器的频率响应');
s=fftfilt(h,s);
figure
plot(s);xlabel('通过成形滤波器后的基带信号');
figure
pwelch(s);%经波形成形滤波器后的功率谱
%已调信号
e=dmod(a,4800,2400,12000,'psk',2);%调制
figure
plot(e);xlabel('已调信号');
enoise=e+randn(1,60);%enoise=e+.1*randn(1,60)不同功率的高斯白噪声
aa=ddemod(enoise,4800,2400,12000,'psk',2);%解调
figure
stem(aa);xlabel('解调后的数字信号');%解调后的数字信号
p=symerr(a,aa)/12 %误码率
%误码率曲线
figure
r=-6:3:12;
rr=10.^(r/10);
pe1=1/2*exp(-rr);%相干解调的误码率曲线
hold on
plot(r,pe1,'r');grid on;
pe2=(1-1/2*erfc(sqrt(rr))).*erfc(sqrt(rr));%差分相干解调的误码率曲线
plot(r,pe2,'b');xlabel('bpsk,dpsk误码率曲线');
set(gca,'XTick',-6:3:18);
matlab高手请支援
应该是这句出现的问题吧,noise=randn(1,length(bpsk));这里bpsk明显没有定义啊,你是想用以g算出来的结果吧,但你前面并没有定义bpsk_output或bpsk与g的关系,因此没有bpsk这个值,程序出错,仔细检查一下看是不是少写了什么式子
关于bpskmatlab代码和bpsk调制及解调matlab的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:包含会议室系统web代码的词条
- 下一篇:jquery代码生成器(js生成器)
相关推荐
- 05-09网页代码,网页代码快捷键
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
- 05-06在线html执行代码(html怎么运行)[20240506更新]
- 05-06源代码管理资源管理器(资源管理器运行代码)[20240506更新]
- 05-06代码源软件库(程序代码库)[20240506更新]
- 05-06点击弹出密码代码(点击弹出密码代码错误)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接