📄 samp7_1.m
字号:
%Samp7_1
clf
Nwin=21;n=0:Nwin-1; %数据总数和序列序号
figure(1)
for ii=1:4
switch ii
case 1
w=boxcar(Nwin); %矩形窗
stext='矩形窗';
case 2
w=hanning(Nwin); %汉宁窗
stext='汉宁窗';
case 3
w=hamming(Nwin); %哈明窗
stext='哈明窗';
case 4
w=bartlett(Nwin); %bartlett窗
stext='Bartelett窗';
end
posplot=['2,2,' int2str(ii)]; %指定绘制窗函数的图形位置
subplot(posplot);
stem(n,w); %绘出窗函数
hold on
plot (n ,w,'r'); %绘制包络线
xlabel('n'); ylabel('w(n)'); title(stext);
hold off; grid on
end
figure(2)
for ii=1:4
switch ii
case 1
w=blackman(Nwin); %Blackman 窗
stext='Blackman窗';
case 2
w=triang(Nwin); %三角窗
stext='三角窗';
case 3
w=kaiser(Nwin,4); %Kaiser窗
stext='Kaiser窗(Beta=4)';
case 4
w=chebwin(Nwin,40); %Chebyshev 窗
stext='Chebyshev窗(r=40)';
end
posplot=['2,2,' int2str(ii)];
subplot(posplot);
stem(n,w); %绘出窗函数
hold on
plot (n,w,'r'); %绘出包络线
xlabel('n');ylabel('w(n)');title(stext);
hold off;grid on;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -