模拟数字调制
河南理工大学万方科技学院 MATLAB课程设计
课程名称:通信原理
设计
目:信号的模拟调制和数字调制团队成员:张品
时 间:
MATLAB仿真教程 孙煊 李鹏 郭亮亮 易雪龙 2012年4月1日
目录
一、目录………………………………………………………………1
二、题目………………………………………………………………2
三、
………………………………………………………………2
四、团队分工…………………………………………………………3
五、设计
…………………………………………………………4
六、总结………………………………………………………………10
七、参考文献…………………………………………………………11
八、附页(源代码)…………………………………………………12
1
二、课设题目
信号的各种模拟调制仿真和数字调制仿真。
三、方案
2
四、团队分工
组长:张品
负责题目的挑选,人员分工,组织编写论文。 成员:孙煊
负责模拟调制部分的编程实现。
李鹏
负责数字调制部分的编程实现。
郭亮亮
负责模拟调制部分资料的收集。
易雪龙
负责数字调制部分资料的收集。
3
五、设计能容
所谓调制,就是把信号转换成适合在信道中传输的一种过程。 1.模拟调制部分
模拟调制分为幅度调制和角度调制。幅度调制又包括常规AM调制,DSB(无直流偏量)双边带调制,SSB单边带调制,VSB残留边带调制。
1幅度调制
在DSB-AM中,已调信号的时域表示如下式:
u ( t ) ? m(t)c(t)?Acm(t)cos(2?fct??c)其中:m(t)是消息信号, c ( t ) ? A c cos( 2 ? f c t ? ? c ) 为载波 fc是载波的频率(单位赫兹Hz),对u(t) 作傅立叶变换,即可得到信号的频域表示:
U(f)?
Ac2
M(f?fc)?
Ac2
M(f?fc)
B传输带宽BT 是消息信号带宽的两倍,即: T
?2W
去掉DSB-AM的一边就得到SSB-AM。依据所保留的边带是上边,还是下边,可以分为USSA和LSSB两种不同的方式,此时信号的
?(t)sin(2?fct)/2u(t)?Acm(t)cos(2?fct)/2?Acm
在频域表示为
fc?|f|?[M(f?fc
)?M(f?fc)]UUSSB(f)??
其它?0
fc?|f|?[M(f?fc)-M(f?fc)]
ULSSB(f)??
其它?0
4
?其中 m ( t ) 是 m ( t) 的希尔伯特变换,定义为 m?(t)?m(t)*(1/?t)
?(f)??jsgn(f)M(f)在频域中为 M
单边SSB幅度调制占有DSB-AM的一半的带宽,即等于信号带宽: BT?W
常规AM与DSB基本一样,知识多添加了一个直流偏量A,保证 A+|m(t)|>=0.
VSB残留边带本人认为与SSB在MATLAB 仿真上是一致的,知识在实现时所用的硬件差异(SSB是理论化的,VSB是实际中能达到的)。所以未做VSB的仿真,只留了咯空壳子。
2角度调制
在PM(相位调制)中则是利用输入信号m(t)控制已调信号u(t)的相位,控制规律为 u(t)?cos(2?fct??(t)??c)
其中u(t)是调制后的信号,fc是载波的频率(单位赫兹Hz),φ0是初始相位,θ(t)是瞬时相位,随着输入信号的振幅变化。 ?(t)?kcm(t)其中 kc为比例常数,称为调制器的灵敏度。
FM(频率调制)与PM的区别仅在于PM是相位偏移随调制信号m(t)线性变化,FM是相位偏移随m(t)的积分呈线性变化。再次就不详解FM。
2.数字调制部分
2.1二进制振幅监控(ASK)
这种调制方式是根据信号的不同,调节正弦波的幅度。
5
载波在数字信号1或0的控制下通或断,在信号为1的状态载波接通,此时传输信道上有载波出现;在信号为0的状态下,载波被关断,此时传输信道上无载波传送。那么在接收端我们就可以根据载波的有无还原出数字信号的1和0。 原理图如下:
2.2二进制频率键控(FSK)
所谓FSK就是用数字信号去调制载波的频率。即用两个不同频率承载二进制1和0的系统。
在基带信号为1时载波频率为F1,当基带信号为0时载波频率为F2,这样调制信号就在基带信号的控制下调制在不同的频率上。可看作是两个不同载波频率的ASK以调信号之和。
原理图如下:
2.3二进制频率键控(PSK)
所谓PSK就是根据数字基带信号的两个电平使载波相位在两个不同的数值之间切换的一种相位调制
。这里用数字基带信号去对相位相差180度的两个载波进行选择。当基带信号为0时调制信号相位从180度开始,当基带信号为1时调制信号相位从0度开始。 6
原理图如下:
3(GUI界面(截图)
PM调制时域图
7
基带信号时域图
SSB上边带调制信号频谱
8
2PSK调制
9
六、总结
原本我们小组所做的程序在MATLAB环境下是可以实现面向对象操作的。操作者可以自由调用我们所编写的程序来实现各种调制,且可自由输入基带信号与载波信号。但是由于能力加上资料有限,我们始终没明白怎
么在GUI界面中实现变量值的插入,最终智能在GUI界面中以某两个例函数作为基带信号和载波信号,来演示信号的各种调制下的时域图豫频谱。这点是我们小组感觉很遗憾的。我们决定在此之后还会继续学习并攻克这个难题。
我们一致认为课程设计对掌握好本门课程的内容十分必要。既能有效的复习前面学习过的几门课的知识,又能对本专业学科有一个系统的认识,还能让我们锻炼使用MATLAB这种工具解决仿真问题的能力,组员都感到从中受益匪浅。
10
参考文献:
【1】 通讯原理MATLAB仿真教程 赵鸿图 茅艳主编
人民邮电出版社出版
【2】MATLAB及其在理工课程中的应用指南(第三版)陈怀琛编著
【2】 现代通信原理与技术概论 程韧,蒋磊 编著 清华大学出版
社 北京交通大学出版社
11
附页(源代码):
function varargout = yanshi1(varargin)
% YANSHI1 M-file for yanshi1.fig
% YANSHI1, by itself, creates a new YANSHI1 or raises the existing %
singleton*.
%
% H = YANSHI1 returns the handle to a new YANSHI1 or the handle to % the existing singleton*.
%
% YANSHI1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in YANSHI1.M with the given input arguments. %
% YANSHI1('Property','Value',...) creates a new YANSHI1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before yanshi1_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to yanshi1_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help yanshi1
% Last Modified by GUIDE v2.5 11-Apr-2012 00:16:23
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @yanshi1_OpeningFcn, ...
'gui_OutputFcn', @yanshi1_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{:});
12
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before yanshi1 is made visible.
function yanshi1_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 yanshi1 (see VARARGIN)
% Choose default command line output for yanshi1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes yanshi1 wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = yanshi1_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 Untitled_6_Callback(hObject, eventdata, handles) % hObject handle to Untitled_6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
t0=2
ts=0.001;
t=-t0/2:ts:t0/2;
13
fc=250
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
plot(t,m);
xlabel('t');
ylabel('基带信号时域图');
% -------------------------------------------------------------------- function Untitled_5_Callback(hObject, eventdata, handles) % hObject handle to Untitled_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_4_Callback(hObject, eventdata, handles) % hObject handle to Untitled_4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_7_Callback(hObject, eventdata, handles) % hObject handle to
Untitled_7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
m=sin(200*t)./(200*t);
m(1001)=1;
fs=1/ts;
F_m=ts*fft(m);
f=linspace(-fs/2,fs/2,length(m));
plot(f,abs(fftshift(F_m)));
xlabel('f');
ylabel('基带信号频谱');
14
% -------------------------------------------------------------------- function Untitled_8_Callback(hObject, eventdata, handles) % hObject handle to Untitled_8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
A0=5;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
c=cos(2*pi*fc*t);
u=(m+5).*c;
plot(t,u);
xlabel('t');
ylabel('AM已调信号时域图');
% -------------------------------------------------------------------- function
Untitled_9_Callback(hObject, eventdata, handles) % hObject handle to Untitled_9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
A0=5;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
c=cos(2*pi*fc*t);
f=linspace(-fs/2,fs/2,length(m));
u=(m+5).*c;
F_u=ts*fft(u);
plot(f,abs(fftshift(F_u)));
xlabel('f');
ylabel('AM已调信号频谱');
15
% -------------------------------------------------------------------- function
Untitled_16_Callback(hObject, eventdata, handles) % hObject handle to Untitled_16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
c=cos(2*pi*fc*t);
u=m.*c;
plot(t,u);
xlabel('t');
ylabel('DSB已调信号时域图');
% -------------------------------------------------------------------- function
Untitled_17_Callback(hObject, eventdata, handles) % hObject handle to Untitled_17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
c=cos(2*pi*fc*t);
f=linspace(-fs/2,fs/2,length(m));
u=m.*c;
F_u=ts*fft(u);
plot(f,abs(fftshift(F_u)));
xlabel('f');
ylabel('DSB已调信号频谱');
% -------------------------------------------------------------------- function Untitled_18_Callback(hObject, eventdata, handles) % hObject handle to Untitled_18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB 16
% handles structure with handles and user data (see GUIDATA) clear;
t0=2;
ts=0.001;
fs=1/ts;
fc=250;
t=-t0/2:ts:t0/2;
m=sin(200*t)./(200*t);
m(1001)=1;
m=m.*m;
c=cos(2*pi*fc.*t);
d=sin(2*pi*fc.*t);
u=(m.*c-imag(hilbert(m)).*d)/2;
plot(t,u);
xlabel('t');
ylabel('SSB上边带已调信号时域图');
axis([-0.1 0.1 -1.2 1.2]);
% -------------------------------------------------------------------- function Untitled_19_Callback(hObject, eventdata, handles) % hObject handle to Untitled_19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
t0=2;
ts=0.001;
fs=1/ts;
fc=250;
t=-t0/2:ts:t0/2;
m=sin(200*t)./(200*t);
m(1001)=1;
m=m.*m;
c=cos(2*pi*fc.*t);
d=sin(2*pi*fc.*t);
u=(m.*c-imag(hilbert(m)).*d)/2;
F_u=ts*fft(u);
f=linspace(-fs/2,fs/2,length(m));
plot(f,abs(fftshift(F_u)));
xlabel('f');
ylabel('SSB上边带已调信号频谱');
% -------------------------------------------------------------------- function
Untitled_20_Callback(hObject, eventdata, handles) 17
% hObject handle to Untitled_20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
t0=2;
ts=0.001;
fs=1/ts;
fc=250;
t=-t0/2:ts:t0/2;
m=sin(200*t)./(200*t);
m(1001)=1;
m=m.*m;
c=cos(2*pi*fc.*t);
d=sin(2*pi*fc.*t);
v=(m.*c+imag(hilbert(m)).*d)/2;
plot(t,v);
xlabel('t');
ylabel('SSB下边带已调信号时域图');
axis([-0.1 0.1 -1.2 1.2]);
% -------------------------------------------------------------------- function
Untitled_21_Callback(hObject, eventdata, handles) % hObject handle to Untitled_21 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
t0=2;
ts=0.001;
fs=1/ts;
fc=250;
t=-t0/2:ts:t0/2;
m=sin(200*t)./(200*t);
m(1001)=1;
m=m.*m;
c=cos(2*pi*fc.*t);
d=sin(2*pi*fc.*t);
v=(m.*c+imag(hilbert(m)).*d)/2;
F_v=ts*fft(v);
f=linspace(-fs/2,fs/2,length(m));
plot(f,abs(fftshift(F_v)));
xlabel('f');
ylabel('SSB下边带已调信号频谱');
% -------------------------------------------------------------------- 18
function Untitled_10_Callback(hObject, eventdata, handles) % hObject
handle to Untitled_10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_11_Callback(hObject, eventdata, handles) % hObject handle to Untitled_11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_12_Callback(hObject, eventdata, handles) % hObject handle to Untitled_12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_23_Callback(hObject, eventdata, handles) % hObject handle to Untitled_23 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_24_Callback(hObject, eventdata, handles) % hObject handle to Untitled_24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB %
handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_22_Callback(hObject, eventdata, handles) % hObject handle to Untitled_22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_25_Callback(hObject, eventdata, handles) % hObject handle to Untitled_25 (see GCBO)
19
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_30_Callback(hObject, eventdata, handles) % hObject handle to Untitled_30 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:2*pi/99:2*pi;
s=[1 0 1 1 0 0 1 0];
m1=[];
for n=1:length(s);
if s(n)==0;
m=zeros(1,100);
else s(n)==1;
m=ones(1,100);
end
m1=[m1 m];
end
plot(m1)
axis([0 100*length(s),-0.1 1.1]);
% -------------------------------------------------------------------- function Untitled_31_Callback(hObject, eventdata, handles) % hObject handle to Untitled_31 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------------- function Untitled_27_Callback(hObject, eventdata, handles) % hObject handle to Untitled_27 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:2*pi/99:2*pi;
s=[1 0 1 1 0 0 1 0];
f=2;
m1=[];
20
c1=[];
for n=1:length(s);
if s(n)==0;
m=zeros(1,100);
else s(n)==1;
m=ones(1,100);
end
c=sin(f*t);
m1=[m1 m];
c1=[c1 c]
end
ask=c1.*m1;
plot(ask)
axis([0 100*length(s),-1.1 1.1]);
% -------------------------------------------------------------------- function
Untitled_28_Callback(hObject, eventdata, handles) % hObject handle to Untitled_28 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:2*pi/99:2*pi;
s=[1 0 1 1 0 0 1 0];
f=100;
m1=[];
c1=[];
b1=[];
for n=1:length(s)
if s(n)==0;
m=-ones(1,100);
b=zeros(1,100)
else s(n)==1;
m=ones(1,100);
b=ones(1,100)
end
c=sin(f*t);
m1=[m1 m];
c1=[c1 c];
b1=[b1 b];
end
psk=c1.*m1;
plot(psk);
21
axis([0 100*length(s) -1.2 1.1]);
% -------------------------------------------------------------------- function
Untitled_29_Callback(hObject, eventdata, handles) % hObject handle to
Untitled_29 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB %
handles structure with handles and user data (see GUIDATA)
t=0:2*pi/99:2*pi;
s=[1 0 1 1 0 0 1 0];
f1=200;
f2=100;
m1=[];
c1=[];
b1=[];
for n=1:length(s)
if s(n)==0;
m=ones(1,100);
c=sin(f2*t);
b=zeros(1,100)
else s(n)==1;
m=ones(1,100);
c=sin(f1*t);
b=ones(1,100)
end
m1=[m1 m];
c1=[c1 c];
b1=[b1 b];
end
fsk=c1.*m1;
plot(fsk)
axis([0 100*length(s) -1.1 1.1]);
% -------------------------------------------------------------------- function Untitled_26_Callback(hObject, eventdata, handles) % hObject handle to Untitled_26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
22
% 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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end
% --- 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)
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (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
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
23
% 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, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (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
radiobutton1
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (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 checkbox1
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
24
% 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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end
% --- 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 = get(hObject,'String') returns popupmenu1 contents as cell array % contents{get(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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array 25
% contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows. %
See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end
% --- Executes on button press in togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (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 togglebutton1
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over edit2. function edit2_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_32_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_32 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear;
A0=5;
t0=2;
26
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
Kp=10;
A=10;
omega=1;
phi=Kp*m;
Spm=A*cos(omega*t+phi);
plot(t,Spm);
xlabel('t');
ylabel('PM已调信号时域图');
% -------------------------------------------------------------------- function
Untitled_33_Callback(hObject, eventdata, handles) % hObject handle to
Untitled_33 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB %
handles structure with handles and user data (see GUIDATA) clear;
A0=5;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
Kp=10;
A=10;
omega=1;
phi=Kp*m;
Spm=A*cos(omega*t+phi);
F_Spm=ts*fft(Spm);
f=linspace(-fs/2,fs/2,length(m));
plot(f,abs(fftshift(F_Spm)));
xlabel('f');
ylabel('PM已调信号频谱');
% -------------------------------------------------------------------- function
Untitled_34_Callback(hObject, eventdata, handles) 27
% hObject handle to Untitled_34 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB %
handles structure with handles and user data (see GUIDATA) clear;
A0=5;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
Kf=10;
A=10;
omega=1;
m=int(m,-t0/2,t0/2);
phi=Kf*m;
Sfm=A*cos(omega*t+phi);
plot(t,Sfm);
xlabel('t');
ylabel('FM已调信号时域图');
% -------------------------------------------------------------------- function
Untitled_35_Callback(hObject, eventdata, handles) % hObject handle to
Untitled_35 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB %
handles structure with handles and user data (see GUIDATA) clear;
A0=5;
t0=2;
ts=0.001;
t=-t0/2:ts:t0/2;
fc=250;
fs=1/ts;
m=sin(200*t)./(200*t);
m(1001)=1;
Kf=10;
A=10;
omega=1;
m=int(m,-t0/2,t0/2);
phi=Kf*m;
Sfm=A*cos(omega*t+phi);
F_Sfm=ts*fft(Sfm);
f=linspace(-fs/2,fs/2,length(m));
28
plot(f,abs(fftshift(F_Sfm))); xlabel('f');
ylabel('FM已调信号频谱');
29