⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 am_mod.m

📁 使用matlab编写M文件实现am调制解调仿真
💻 M
字号:
function varargout = am_mod(varargin)

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

% Last Modified by GUIDE v2.5 04-Oct-2007 22:39:46

% 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
% End initialization code - DO NOT EDIT


% --- 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(gcf,'Color',[1 1 0]);
set(handles.carrier,'Value',0.5);
set(handles.mod,'Value',0.5);
handles.ejex=0:1/1000:.5;
axes(handles.axes1)
y_m=cos(2*pi*25*handles.ejex)+1;
plot(handles.ejex,y_m,'--','Color',[1 0 0]);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 SIGNAL');
ylabel('Amplitude');
xlabel('Time (s)');
axes(handles.axes2)
plotspec(y_am,1/1000);
title('SPECTRUM');
%zoom on
% Choose default command line output for am_mod
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes am_mod wait for user response (see UIRESUME)
% 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=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;
plot(handles.ejex,y_am)
hold off;
title('AM SIGNAL');
ylabel('Amplitude');
xlabel('Time (s)');
axes(handles.axes2)
plotspec(y_am,1/1000)
title('SPECTRUM');
a=get(handles.zoom,'Value');
if a==1
    zoom on;
    set(handles.zoom,'String','ZOOM ON');
else
    zoom off;
    set(handles.zoom,'String','ZOOM OFF');
end
% --- Executes during object creation, after setting all properties.
function mod_CreateFcn(hObject, eventdata, handles)
% hObject    handle to mod (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function carrier_Callback(hObject, eventdata, handles)
% hObject    handle to carrier (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_c=200*get(hObject,'Value');
f_m=50*get(handles.mod,'Value');
set(handles.fc,'String',f_c);
set(handles.fm,'String',f_m);
axes(handles.axes1)
y_m=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;
plot(handles.ejex,y_am)
hold off;
title('AM SIGNAL');
ylabel('Amplitude');
xlabel('Time (s)');
axes(handles.axes2)
plotspec(y_am,1/1000)
title('SPECTRUM');
a=get(handles.zoom,'Value');
if a==1
    zoom on;
    set(handles.zoom,'String','ZOOM ON');
else
    zoom off;
    set(handles.zoom,'String','ZOOM OFF');
end
% --- Executes during object creation, after setting all properties.
function carrier_CreateFcn(hObject, eventdata, handles)
% hObject    handle to carrier (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end




% --- 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','ZOOM ON');
else
    zoom off;
    set(handles.zoom,'String','ZOOM OFF');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -