天天看点

【数字信号调制】基于matlab实现AM调制系统附GUI界面

1 内容介绍

在设计通信系统数字信号仿真平台的基础上,应用MATLAB软件对二进制数字调制信号进行仿真,具体包括对二进制数字调制信号中的二进制幅度键控信号、二进制频移键控信号和二进制相移键控信号的仿真,并应用GUI的相应控件搭建通信系统数字信号的仿真平台。

2 部分代码

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%                                                                    %

%                      AM modulation with GUI                        %

%                                                                    %

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = am_mod(varargin)

% Edit the above text to modify the response to help am_mod

% Last Modified by GUIDE v2.5 02-Jun-2022 16:43:51

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @am_mod_OpeningFcn, ...

                   'gui_OutputFcn',  @am_mod_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

% --- Executes just before am_mod is made visible.

function am_mod_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 am_mod (see VARARGIN)

set(handles.carrier,'Value',0.5);

set(handles.mod,'Value',0.5);

handles.ejex=0:1/1000:.5;

axes(handles.axes1)

y_m=.5*cos(2*pi*25*handles.ejex)+1;

plot(handles.ejex,y_m,'--','Color',[1 0 1]);hold on;

y_c=cos(2*pi*100*handles.ejex);

y_am=y_m.*y_c;

plot(handles.ejex,y_am)

hold off;

title('AM信号');

ylabel('振幅');

xlabel('时间(s)');

axes(handles.axes2)

plotspec(y_am,1/1000);

title('光谱');

%zoom on

% Choose default command line output for am_mod

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = am_mod_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 slider movement.

function mod_Callback(hObject, eventdata, handles)

% hObject    handle to mod (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,'Value') returns position of slider

%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

f_m=50*get(hObject,'Value');

f_c=200*get(handles.carrier,'Value');

set(handles.fc,'String',f_c);

set(handles.fm,'String',f_m);

axes(handles.axes1)

y_m=.5*cos(2*pi*f_m*handles.ejex)+1;

plot(handles.ejex,y_m,'--','Color',[1 0 0]);hold on;

y_c=cos(2*pi*f_c*handles.ejex);

y_am=y_m.*y_c;

% --- Executes on button press in zoom.

function zoom_Callback(hObject, eventdata, handles)

% hObject    handle to zoom (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of zoom

a=get(hObject,'Value');

if a==1

    zoom on;

    set(handles.zoom,'String','放大');

else

    zoom off;

    set(handles.zoom,'String','缩小');

end

 c  

% --- Executes on button press in close.

function close_Callback(hObject, eventdata, handles)

% hObject    handle to close (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of close

clc

close all

3 运行结果

【数字信号调制】基于matlab实现AM调制系统附GUI界面
【数字信号调制】基于matlab实现AM调制系统附GUI界面

4 参考文献

博主简介:擅长​​智能优化算法​​、​​神经网络预测​​、​​信号处理​​、​​元胞自动机​​、​​图像处理​​、​​路径规划​​、​​无人机​​、​​雷达通信​​、​​无线传感器​​等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。