扩频通信基于matlab GUI扩频通信系统仿真(带面板)含Matlab源码 1587期

Posted 紫极神光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了扩频通信基于matlab GUI扩频通信系统仿真(带面板)含Matlab源码 1587期相关的知识,希望对你有一定的参考价值。

一、扩频通信系统简介

** 扩频通信的基本原理**
1 扩频通信
所谓扩展频谱通信,可简单表述如下:“扩频通信技术是一种信息传输方式,其信号所占有的频带宽度远大于所传信息必需的最小带宽;频带的扩展是通过一个独立的码序列来完成,用编码及调制的方法来实现的,与所传信息数据无关;在接收端则用同样的码进行相关同步接收、解扩及恢复所传信息数据”。
扩频通信的基本特点,是传输信号所占用的频带宽度(W)远大于原始信息本身实际所需的最小带宽(B),其比值称为处理增益(Gp)。总之,我们用扩展频谱的宽带信号来传输信息,就是为了提高通信的抗干扰能力,即在强干扰条件下保证可靠安全地通信。这就是扩展频谱通信的基本思想和理论依据。
扩频通信的性能。扩频通信的可行性是从信息论和抗干扰理论的基本公式中引伸而来的。信息论中关于信息容量的香农( Shannon) 公式为:C=Blog2 ( 1+ SN)其中: C 为信道容量( 即极限传输速率) , B 为信号频带宽度, S 为信号功率, N 为噪声功率。Shannon 公式说明, 在给定的传输速率不变的条件下, 频带宽度和信噪比P 可以互换, 即可以通过增加频带宽度, 在信噪比较低的情况下传输信息。扩展频谱以换取信噪比要求的降低, 正是扩频通信的重要特点, 并由此为扩频通信的应用奠定了基础。扩频通信的一个重要参数是扩频增益, 反映了系统抗干扰能力的强弱, 是对信噪比改善程度的度量, 定义为接收机相关器输出信噪比和输入信噪比之比, 即

2 直接序列扩频
直接序列扩频就是直接用具有高码率的扩频码序列在发送端去扩展信号的频谱。而在接收端, 用相同的扩频码序列去进行解扩, 将展宽的扩频信号还原成原始的信息。直扩通信系统原理如图1 所示。


5 高斯加性白噪声(AWNG)
白噪声是指功率谱密度在整个频域内均匀分布的噪声。即其功率谱密度:

二、部分源代码

function varargout = my_work(varargin)
% MY_WORK MATLAB code for my_work.fig
%      MY_WORK, by itself, creates a new MY_WORK or raises the existing
%      singleton*.
%
%      H = MY_WORK returns the handle to a new MY_WORK or the handle to
%      the existing singleton*.
%
%      MY_WORK('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MY_WORK.M with the given input arguments.
%
%      MY_WORK('Property','Value',...) creates a new MY_WORK or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before my_work_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to my_work_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 my_work

% Last Modified by GUIDE v2.5 17-May-2019 11:55:22

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @my_work_OpeningFcn, ...
                   'gui_OutputFcn',  @my_work_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin1)
    gui_State.gui_Callback = str2func(varargin1);
end

if nargout
    [varargout1:nargout] = gui_mainfcn(gui_State, varargin:);
else
    gui_mainfcn(gui_State, varargin:);
end
% End initialization code - DO NOT EDIT


% --- Executes just before my_work is made visible.
function my_work_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 my_work (see VARARGIN)

% Choose default command line output for my_work
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes my_work wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = my_work_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
varargout1 = handles.output;


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contentsget(hObject,'Value') returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
set(hObject, 'String', '直接扩频', '跳频');

% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
%        contentsget(hObject,'Value') returns selected item from popupmenu2


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
set(hObject, 'String', 'm序列', 'gold码','walsh码');

% --- 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)
figure(1);
clf;
code_length = 100;
rand_x=zeros(1,code_length);
rng('default');
my_x=rand(1,code_length);
for i=1:code_length
    if(my_x(i)>=0.5)
        rand_x(i)=1;
    end
end
subplot(2,1,1);
plot(rand_x);
title('随机信源序列');
axis([0 code_length*1.1 -2 2]);
grid on;
sampling_1=10;
rand_x1=signal_sampling(sign(rand_x-0.5),sampling_1);%变为双极性,且每个码元内采样10个点
seq_length=length(rand_x1);
subplot(2,1,2);
plot(rand_x1);
axis([0 seq_length*1.1 -2 2]);
title('采样后的双极性信源序列');
grid on;
                
popup_sel_index_1 = get(handles.popupmenu1, 'Value');
popup_sel_index_2 = get(handles.popupmenu2, 'Value');
sig_noise = get(handles.edit3,'string');
s_n=str2double(sig_noise);

switch popup_sel_index_1
    case 1
        pn_seqence=my_seq(seq_length,popup_sel_index_2);
        figure(2);
        clf;
        plot(pn_seqence);
        axis([0 250 -2 2]);
        title('伪随机码序列');
        grid on;
        rec_signal=direct_spread(rand_x1,pn_seqence,s_n);
    case 2
        rec_signal=freq_hopping(rand_x1,popup_sel_index_2,s_n);
end

signal_x=rec_signal_jud(rec_signal,sampling_1);
[m_1,n_1]=symerr(signal_x,rand_x);%m表示误码个数,n表示误码率
set(handles.edit1,'string',m_1);
set(handles.edit2,'string',n_1);

n_sample=0:(code_length-1);
f=n_sample*2*pi/code_length;

axes(handles.axes1);
cla;
plot(rand_x);
axis([0 code_length*1.1 -1 2]);
title('信源序列');
grid on;

axes(handles.axes2);
cla;
y1_abs=abs(fft(rand_x));
plot(f(1:floor(code_length/2)),y1_abs(1:floor(code_length/2)));
title('信源序列频谱图');
grid on;
axes('position',[0.55 0.5 0.15 0.15])
plot(f(1:round(0.2*code_length)),y1_abs(1:round(0.2*code_length)));
title('局部频谱图');
xlim([0,0.5]);

axes(handles.axes3);
cla;
plot(signal_x);
axis([0 code_length*1.1 -1 2]);
title('恢复出的信源序列');
grid on;

axes(handles.axes4);
cla;
y2_abs=abs(fft(signal_x));
plot(f(1:floor(code_length/2)),y2_abs(1:floor(code_length/2)));
title('恢复出的信源序列的频谱图');
grid on;
axes('position',[0.55 0.15 0.15 0.15])
plot(f(1:round(0.2*code_length)),y2_abs(1:round(0.2*code_length)));
title('局部频谱图');
xlim([0,0.5]);


function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double

三、运行结果



四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.

以上是关于扩频通信基于matlab GUI扩频通信系统仿真(带面板)含Matlab源码 1587期的主要内容,如果未能解决你的问题,请参考以下文章

扩频通信基于matlab直接序列扩频系统仿真含Matlab源码 1529期

扩频通信基于matlab CDMA直接序列扩频系统仿真含Matlab源码 1528期

扩频通信基于matlab扩频通信Gold序列特性仿真含Matlab源码 1522期

扩频通信基于matlab扩频+解扩仿真含Matlab源码 1495期

MATLAB教程案例4直接序列扩频通信系统的MATLAB仿真

扩频调制解调技术