【数字信号调制】基于matlab GUI AM+DSB+SSB+ASK+FSK+PSK调制解调【含Matlab源码 058期 】

197 阅读4分钟

一、简介

基于matlab GUI AM+DSB+SSB+ASK+FSK+PSK调制解调

二、源代码

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

% Last Modified by GUIDE v2.5 02-Sep-2019 08:36:43

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

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

% Update handles structure
guidata(hObject, handles);

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


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


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


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

%=========程序代码 ======== 
clc ;clear all;
hold on;
Fs=960;  %采样频率
N=960;    %采样点
n=0:N-1;t=n/Fs;  %时间序列
A0=10;  %载波信号振幅 
A1=1;   %调制信号振幅 
fc=120;  %载波信号频率 
fm=30;    %调制信号频率
f=n*Fs/N;  %频率
w0=2*fc*pi; 
w1=2*fm*pi;

Uc=A0*cos(w0*t);     %载波信号 
C1=fft(Uc);             %对载波信号进行傅里叶变换 
cxf=abs(C1);           %进行傅里叶变换  
% figure(1); 
hold on;
 
subplot(6,2,2); plot(f(1:N/2),cxf(1:N/2));title('载波信号频谱'); 
% subplot(6,2,2)
% f = fftshift(C1);
% w = linspace(-Fs/2, Fs/2, N);%频率坐标,单位Hz
% plot(w,abs(f));
% title('信号的频谱');
% xlabel('频率(Hz)');

 
 
subplot(6,2,3); plot(t,mes); title('调制信号');axis([0 0.5 0 2]);  
subplot(6,2,4);  plot(f(1:N/2),zxc(1:N/2)); title('调制信号频谱'); axis([0 50 0 500])


Uam=modulate(mes,fc,Fs,'am');%AM 已调信号
C3=fft(Uam);              %  对AM已调信号进行傅里叶变换
asd=abs(C3);
% figure(3)
 
subplot(6,2,6);plot(f(1:N/2),asd(1:N/2)),grid; title('AM已调信号频谱'); 
 
 
% figure(4)
 
axis([0 0.5 0 2]);
subplot(6,2,8); plot(f(1:N/2),wqe(1:N/2)),grid; title('AM解调信号频谱');

k=awgn(Uam,10);  %加大噪声,信噪比为10
pp=fft(k,960);
zs=abs(pp);
% figure(6)
subplot(6,2,9);plot(t,k);axis([0 0.5 -2 2])
title('加噪声后得到AM信号时域波形');%加大噪声后得到AM信号时域波形
subplot(6,2,10);plot(f(1:N/2),zs(1:N/2));
title('加噪声后得到AM信号频域波形'); %加大噪声后得到AM信号频域波形
grid on;

qaz=demod(k,fc,Fs,'am'); %加大噪声后解调
 
subplot(6,2,11); ;title('加大噪声后解调得到信号时域波形'); %加大噪声后解调得到信号时域波形
 
edc=abs(wsx);
subplot(6,2,12);
plot(f(1:N/2),edc(1:N/2));
hold off;
title('加大噪声后解调得到信号频域波形');  %加大噪声后解调得到信号频域波形
grid on;
function [ t, st ] = F2T( f, sf )
df = f(2)-f(1);
Fmx = f(end)-f(1)+df;
dt = 1/Fmx;
N = length(sf);
 
sff = fftshift(sf);
st = Fmx * ifft(sff);
end
% --- Executes just before communication is made visible.
function communication_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 communication (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


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


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


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

三、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、备注

版本:2014a