?? caiyang.m
字號:
%caiyang 演示采樣定理,時域采樣,頻譜周期延拓
%同時演示采樣頻率小于2*fc時,產生的混疊效應
clf reset
set(gcf,'unit','normalized','position',[0.1,0.2,0.5,0.5]);
set(gcf,'defaultuicontrolunits','normalized');
haxes1=axes('position',[0.05,0.2,0.4,0.2],...
'xlim',[-5,5],'ylim',[-5,5]);
haxes2=axes('position',[0.5,0.2,0.4,0.2],...
'xlim',[-1,1],'ylim',[0,1]);
haxes3=axes('position',[0.05,0.45,0.4,0.2],...
'xlim',[-5,5],'ylim',[-5,5]);
haxes4=axes('position',[0.5,0.45,0.4,0.2],...
'xlim',[-1,1],'ylim',[0,1]);
haxes5=axes('position',[0.05,0.7,0.4,0.2],...
'xlim',[-20,20],'ylim',[-5,5]);
%繪出初始時的時域信號
t=-0.05:0.001:0.05;
fc=100; %這里假設三角波的頻帶寬度為100Hz
y=fc/2*sinc(fc*t/4).*sinc(fc*t/4);
plot(t,y);
haxes6=axes('position',[0.5,0.7,0.4,0.2],...
'xlim',[-1,1],'ylim',[0,1.1]);
%繪出頻譜
x1=1:-0.1:0; x2=0:0.1:0.9;
x3=[x2,x1];
k=-10:10;
df=0.01;%這里假設fc=100,df代表10HZ 所以fc占用0.1
f=k*df;
plot(f,x3);axis([-1,1,0,1.1]);
htext1=uicontrol(gcf,'style','text',...
'position',[0.05,0.05,0.6,0.05],...
'backgroundcolor','white',...
'fontsize',10,...
'visible','on',...
'string','輸入采樣頻率(信號頻率為100Hz,100<fs<900)');
htext2=uicontrol(gcf,'style','text',...
'position',[0.2,0.92,0.15,0.05],...
'fontsize',10,...
'string','時 域');
htext3=uicontrol(gcf,'style','text',...
'position',[0.65,0.92,0.15,0.05],...
'fontsize',10,...
'string','頻 域');
hedit=uicontrol('style','edit',...
'position',[0.7,0.05,0.2,0.05],...
'backgroundcolor','white',...
'visible','on');
set(hedit,'CallBack',['call_caiyang1(haxes4);',...
'call_caiyang3(haxes3);',...
'call_caiyang4(haxes1,fc);',...
'call_caiyang2(haxes2);']);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -