function varargout = GUI_2FSK(varargin)
% GUI_2FSK MATLAB code for GUI_2FSK.fig
% GUI_2FSK, by itself, creates a new GUI_2FSK or raises the existing
% singleton*.
%
% H = GUI_2FSK returns the handle to a new GUI_2FSK or the handle to
% the existing singleton*.
%
% GUI_2FSK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_2FSK.M with the given input arguments.
%
% GUI_2FSK('Property','Value',...) creates a new GUI_2FSK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_2FSK_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_2FSK_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help GUI_2FSK
% Last Modified by GUIDE v2.5 30-Nov-2018 14:09:53
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_2FSK_OpeningFcn, ...
'gui_OutputFcn', @GUI_2FSK_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before GUI_2FSK is made visible.
function GUI_2FSK_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUI_2FSK (see VARARGIN)
% Choose default command line output for GUI_2FSK
handles.output = hObject;
i=20; %二级制基带数据个数
fc=1000; %抽样频率
j=i*fc;
s=round(rand(1,i)); %产生二级制基带数
t=linspace(0,i,j);
f1=10; %载波1频率
f2=30; %载波2频率
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%产生基带信号
s1=t;
for n=1:i
if s(n)<1;
for m=j/i*(n-1)+1:j/i*n
s1(m)=0;
end
else
for m=j/i*(n-1)+1:j/i*n
s1(m)=1;
end
end
end
s2=t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%基带信号求反
for n=1:j;
if s1(n)>=1;
s2(n)=0;
else
s2(n)=1;
end
end;
%figure(1);subplot(411);plot(t,s1);title('基带信号');axis([0,i,-1,2]);
%subplot(412);plot(t,s2);title('基带信号求反');axis([0,i,-1,2]);
F1=cos(2*pi*f1*t); %载波信号1
F2=cos(2*pi*f2*t); %载波信号2
%subplot(413);plot(t,F1);title('载波信号1');
Fsk=s1.*F1+s2.*F2; %2Fsk调制
%figure(2);subplot(311);plot(t,Fsk);title('2FSK调制信号')
SNR_dB=15; %定义信噪比
SNR=10^(SNR_dB/10); %定义线性信噪比
Ps=1; %发射功率
Pn=Ps/SNR; %噪声方差
F3=cos(2*pi*f1*t+pi/4);
F4=cos(2*pi*f2*t+pi/4);
Fsk1=s1.*F3+s2.*F4;
t1=length(t);
z=sqrt(Pn/2)*randn(1,t1);
h=1; %AWGN信道下,信道增益h=1
Fskh=Fsk1*h+z; %通过AWGN信道后产生pi/4的相移
%subplot(312);plot(t,z); %噪声波形 title('噪声波形')
%subplot(313);plot(t,Fskh);title('通过信道加噪声后的接受信号'); axis([0,i,-1,1]);
b1=fir1(101,[10/500 15/500]); %设置带通滤波器参数
b2=fir1(101,[30/500 40/500]);
Fskh1=filter(b1,1,Fskh); %经过带通滤波器后的信号
Fskh2=filter(b2,1,Fskh);
%figure(3);subplot(211);plot(t,Fskh1);title('经过带通滤波器b1后的波形');axis([0,i,-1,1]);
%subplot(212);plot(t,Fskh2);title('经过带通滤波器b2后的波形');
FskH1=Fskh1.*Fskh1;
FskH2=Fskh2.*Fskh2; %经过相乘器
%figure(4);subplot(211);plot(t,FskH1);title('经过相乘器后Fskh1的波形')
%subplot(212);plot(t,FskH2);title('经过相乘器后Fskh2的波形')
bn=fir1(101,[2/500 10/500]); %设置低通滤波器参数
st1=filter(bn,1,FskH1); %经过低通滤波器
st2=filter(bn,1,FskH2);
%figure(5) ;subplot(211);plot(t,st1);title('经过低通滤波器bn后的波形')
%subplot(212);plot(t,st2);title('经过低通滤波器bn后的波形')
%判决
st1_sum=zeros(1,i);
st2_sum=zeros(1,i);
for p=1:i %抽样判决,在每一个基带代码带宽内按抽样频率抽样并相加比较
for j=1000*(p-1)+1:1000*p
st1_sum(p)=st1_sum(p)+st1(j);
st2_sum(p)=st2_sum(p)+st2(j);
end
if(st1_sum(p)>=st2_sum(p))
s_est(p)=1;
else s_est(p)=0;
end
end
s3=t; %解调后的基带信号
for n=1:i
if s_est(n)<1;
for m=j/i*(n-1)+1:j/i*n
s3(m)=0;
end
else
for m=j/i*(n-1)+1:j/i*n
s3(m)=1;
end
end
end
%figure(6);subplot(211);plot(t,st);title('经过抽样判决器后的波形')
%subplot(212);plot(t,Fskh);title('原始的波形');axis([0,i,-1,1]);
%%%%%%%%%%%%%%%%%实际误码率曲线和理论误码率对比
PBSUM=0;
for n=1:10 %信噪比循环
for m=1:1000 %蒙特卡洛循环
SNR=n;
Ps=100; %发射功率
Pn=Ps/SNR;
z=sqrt(Pn/2)*randn(1,t1); %噪声方差
h=1;
Fskh=Fsk1*h+z; %通过AWGN信道后产生pi/4的相移
b1=fir1(101,[10/500 15/500]);
b2=fir1(101,[30/500 40/500]); %设置带通参数
Fskh1=filter(b1,1,Fskh);
Fskh2=filter(b2,1,Fskh); %经过带通滤波器后的信号
FskH1=Fskh1.*Fskh1;
FskH2=Fskh2.*Fskh2; %经过相乘器
bn=fir1(101,[2/500 10/500]); %设置低通滤波器参数
st1=filter(bn,1,FskH1); %经过低通滤波器
st2=filter(bn,1,FskH2);
st1_sum1= zeros(1,i);
st2_sum1= zeros(1,i);
for i=1:20 %抽样判决,在每一个基带代码带宽内按抽样频率抽样并相加比较
for j=1000*(i-1)+1:1000*i
st1_sum1(i)=st1_sum1(i)+st1(j);
st2_sum1(i)=st2_sum1(i)+st2(j);
end
if(st1_sum1(i)>=st2_sum1(i))
s_est(i)=1;
else s_est(i)=0;
end
end
for k=1:20 %原二进制信号与解调后信号相加等于一,则误码加一
if(s(k)+s_est(k)==1)
PBSUM=PBSUM+1;
end
end
end
Pb(n)=PBSUM/1000/10;
PBSUM=0;
end
SNRX=1:10;
%figure(7); plot(SNRX,Pb); %实际误码率画图
grid on;
hold on
for j=1:10
snr1(j)=10^(j/10); %将信噪比的值由dB转化为数值
PB(j)=erfc(sqrt(snr1(j)/2))/2; %理论误码率计算
end
SNRX=1:10;
%scatter(SNRX,PB); %理论误码率画图
handles.t=t;
handles.s1=s1;
handles.s2=s2;
handles.F1=F1;
handles.F2=F2;
handles.Fsk=Fsk;
handles.z=z;
handles.Fskh=Fskh;
handles.Fskh1=Fskh1;
handles.Fskh2=Fskh2;
handles.FskH1=FskH1;
handles.FskH2=FskH2;
handles.st1=st1;
handles.st2=st2;
handles.s1=s1;
handles.s3=s3;
handles.SNRX=SNRX;
handles.Pb=Pb;
handles.PB=PB;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUI_2FSK wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_2FSK_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
plot(handles.t,handles.s1);title('基带信号');
axes(handles.axes2);
plot(handles.t,handles.s2);title('基带信号求反');
axes(handles.axes3);
plot(handles.t


海神之光
- 粉丝: 6w+
最新资源
- 技术转移机构如何利用AI+数智应用优化技术供需匹配?.docx
- 技术转移机构如何利用AI+数智应用应对市场竞争加剧和服务升级压力?.docx
- 技术转移机构如何通过AI+数智应用打造差异化竞争力?.docx
- 技术转移机构如何通过AI+数智应用实现服务效率与质量的双重提升?.docx
- 技术转移机构如何通过AI+数智应用手段拓展客户群体并实现业务增长?.docx
- 技术转移机构如何通过AI+数智应用转型提升专业服务能力?.docx
- 技术转移机构数字化转型挑战重重,如何通过AI+数智应用快速提升服务效率和质量?.docx
- 技术转移机构想提升品牌价值并拓展客户,有哪些基于AI+数智应用的可行方法?.docx
- 技术转移机构业务AI+数智应用转型有哪些有效途径?.docx
- 技术转移机构在AI+时代如何高效应对市场竞争与服务升级挑战?.docx
- 技术转移机构在AI+时代如何提升服务效率和质量?.docx
- 技术转移机构在AI+时代如何突破传统服务瓶颈实现业务升级?.docx
- 技术转移机构在AI+时代如何应对市场竞争与服务升级的双重压力?.docx
- 技术转移机构在AI+数智应用转型中常遇哪些难题?.docx
- 技术转移机构在AI+数智应用转型中面临哪些核心挑战?如何快速构建智能服务体系?.docx
- 技术转移机构在AI+数智应用转型中面临哪些挑战?如何解决?.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


