天天看點

【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】

二、數字信号調制系統簡介

​二進制數字信号調制原理​

數字調制是指用數字基帶信号對載波的某些參量進行控制, 使載波的這些參量随基帶信号的變化而變化。在通信系統中, 作為載波的正弦波有幅度、頻率和相位3個參數, 對應的也就有3種基本的調制方式:調幅、調頻和調相。由于數字信号不同與模拟信号的特殊性, 在數字載波通信中, 這3種基本的調制方式分别被稱為幅移 (ASK) 、頻移鍵控 (FSK) 和相移鍵控 (PSK) 。調制信号是二進制數字基帶信号時, 這種調制稱為二進制數字調制。在二進制數字調制中, 載波的幅度、頻率和相位隻有兩種變化方式。

​1 ASK調制​

振幅鍵控是利用載波的幅度變化來傳遞數字資訊, 而其頻率和初相位保持不變。二進制幅度鍵控 (2ASK) 方式是數字調制方式中出現最早也是最簡單的一種方法。這種方法最初用于電報系統, 二進制振幅鍵控常常作為研究其它數字調制方式的基礎。2ASK調制信号隻有0或1兩個電平相乘的, 結果相當于将載頻或者關斷, 或者接通, 它的實際意義是當調制的數字信号為“1”時, 傳輸載波;當調制的數字信号為“0”時, 不傳輸載波。

2ASK信号的一般表達式為:

【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】

其中

【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】

​2 FSK調制​

頻移鍵控是利用載波的頻率變化來傳遞數字資訊。在2FSK中, 載波的頻率随二進制基帶信号在f1和f0的兩個頻率點變化。它的實際意義是當調制的數字信号為“1”或“0”時傳輸f1或f2頻率的載波。

【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】

其中ω1=2nf1, ω0=2nf0, θn為頻率為f1的載波的初始相位, φn為頻率為f0的載波的初始相位。令 為Dn的反碼, 即

【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】

則2FSK信号可表示為:

【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】

​3 PSK調制​

相移鍵控是利用載波的相位變化來傳遞數字資訊, 而振幅和頻率保持不變。PSK調制時, 載波的相位随調制信号狀态不同而改變。如果兩個頻率相同的載波同時開始振蕩, 這兩個頻率同時達到正最大值, 同時達到零值, 同時達到負最大值, 此時它們就處于“同相”狀态;如果一個達到正最大值時, 另一個達到負最大值, 則稱為“反相”。一般把信号振蕩一次 (一周) 作為360度。如果一個波比另一個波相差半個周期, 我們說兩個波的相位差180度, 也就是反相。當傳輸數字信号時, “1”碼控制發0度相位, “0”碼控制發180度相位。相移鍵控有很好的抗幹擾性, 在有衰落的信道中也能獲得很好的效果。

三、部分源代碼

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

% Last Modified by GUIDE v2.5 20-Dec-2020 17:01:23

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @display_signal_OpeningFcn, ...
                   'gui_OutputFcn',  @display_signal_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 display_signal is made visible.
function display_signal_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 display_signal (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = display_signal_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 selection change in type.
function type_Callback(hObject, eventdata, handles)
% hObject    handle to type (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 type contents as cell array
%        contents{get(hObject,'Value')} returns selected item from type


% --- Executes during object creation, after setting all properties.
function type_CreateFcn(hObject, eventdata, handles)
% hObject    handle to type (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



function Fb_Callback(hObject, eventdata, handles)
% hObject    handle to Fb (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 Fb as text
%        str2double(get(hObject,'String')) returns contents of Fb as a double


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

% Hint: edit 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



function Fc_Callback(hObject, eventdata, handles)
% hObject    handle to Fc (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 Fc as text
%        str2double(get(hObject,'String')) returns contents of Fc as a double


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

% Hint: edit 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



function Bit_Callback(hObject, eventdata, handles)
% hObject    handle to Bit (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 Bit as text
%        str2double(get(hObject,'String')) returns contents of Bit as a double


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

% Hint: edit 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


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


tempobj=findobj(gcbf,'tag','type');
modu_type=get(tempobj,'value');

fc=eval(get(handles.Fc,'String'));              %可選參數設定
B=str2double(get(handles.Fb,'String'));
DisBit=str2double(get(handles.Bit,'String'));

 switch(modu_type)
     case 1
            nper=B/fc;       %一個碼元中所包含的載波周期數
            nsamp=128;       %過采樣率
            fs=nsamp*B;      %采樣率
            Ts=1/fs;         %采樣周期
            NumBit=1024;       %資料位數

            %數字基帶信号産生
            Data=randint(1,NumBit);
            NumSample=NumBit*nsamp;    %總采樣點數
            signal=zeros(1,NumSample);
            start=1;
            for i=1:NumBit
                if(Data(i))
                    signal(start:start+nsamp-1)=1;
                end
                start=start+nsamp;
            end
            t=0:Ts:Ts*(NumSample-1);
            ASK_signal=signal.*sin(2*pi*fc*t);      

四、運作結果

【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】
【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】
【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】
【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】
【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】
【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】
【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】
【數字信号調制】基于matlab GUI數字信号調制系統【含Matlab源碼 1030期】

五、matlab版本及參考文獻

​1 matlab版本​

2014a

​2 參考文獻​

[1] 沈再陽.精通MATLAB信号處理[M].清華大學出版社,2015.

[2]高寶建,彭進業,王琳,潘建壽.信号與系統——使用MATLAB分析與實作[M].清華大學出版社,2020.

[3]王文光,魏少明,任欣.信号處理與系統分析的MATLAB實作[M].電子工業出版社,2018.

繼續閱讀