📄 cai2.m
字号:
k=0;
while k==0
fs=input('请输入采样频率fs:');
fc=100;
subplot(3,1,1)
t=-0.05:0.001:0.05;
y=fc*[sinc(fc*t/4)].^2/2;
plot(t,y)
title('时域信号ya(t)')
subplot(3,1,2)
T=1/fs;
t1=-0.05:T:0.05;
y1=fc*[sinc(fc*t1/4)].^2/2;
n=0.1/T+1
h=ones(1,n);
stem(t1,h,'^')
title('采样序列h(t)')
subplot(3,1,3)
stem(t1,y1,'^')
title('采样后序列ya^(t)');pause;
figure
subplot(3,1,1)
x=[0 1 0];
t=[-0.1 0 0.1];
plot(t,x)
title('时域信号的频谱Y(jw)')
xlabel('w');ylabel('Y(jw)');
axis([-0.5,0.5,0,1])
wc=0.1;ws=(fs/fc)*wc;N=fix(0.5/ws)
for i=0:1:N
subplot(3,1,2)
stem(-ws*i,1,'^');axis([-0.5,0.5,0,1]);hold on;
stem(ws*i,1,'^');axis([-0.5,0.5,0,1])
subplot(3,1,3)
t1=[-ws*i-wc,-ws*i,-ws*i+wc];t2=[ws*i-wc,ws*i,ws*i+wc]
x=[0,1,0];
plot(t1,x,t2,x);hold on;axis([-0.5,0.5,0,1]);pause(1)
end
if ws<2wc
for i=0:1:N
subplot(3,1,3)
plot([-ws*(i+1)+wc,-ws*i-wc],[2-10*ws,2-10*ws],'-',[ws*(i+1)-wc,ws*i+wc],[2-10*ws,2-10*ws],'-');
hold on
end
end
disp('1、选择1改变采样频率fs,继续')
disp('2、按其他输入退出程序')
j=input('请选择:');
if j==1
clear;k=0;
else clear;k=1;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -