📄 fdslide.m
字号:
function slide=fdslide
% This is a slideshow file for use with fdshow.m
% Too see it run, type 'fdshow',
% Copyright (c) 1984-97 by The MathWorks, Inc.
% $Revision: 5.16 $
global doi;
if nargout<1,
fdshow
else
%for slidenum=1:25
% slide(slidenum).code2={};
% slide(slidenum).next=slidenum+1;
%end;
%---------------------------------------------------------------------------------------
%for each slide:
% ttl: the title of this slide which displays the path
% code1: the code which will be evaluated in the upper part of the figure(axes1)
% %%%%%%%code2: the code which will be evaluated in the lower part of the figure(axes2)
% next: the index of next slide
% it is a row of indexes, paralize with the slide's next directions according
% to the choice of the uicontrols
% nextcode:
%---------------------------------------------------------------------------------------
dfOriginalIndex=16; % a temp varialbe for connecting with the work by Wei Guo
%slideData=get(gcf,'UserData');
for i=1: dfOriginalIndex+30
slide(i).ttl={};
slide(i).code1={};
% slide(i).code2={};
slide(i).text={};
slide(i).next=[];
end
%========== Slide 1 ==========
%=====choose the DF/AF========
slide(1).ttl='滤波器设计';
%slide(1).title='Filter Bank Design';
slide(1).code1={'滤波器设计类型为数字滤波器(Digital Filter)'};
%' load logo',
%' surf(L,R), colormap(M)',
%' n = length(L(:,1));',
%' axis off, axis([1 n 1 n -.2 .8]), view(-37.5,30)',
%'title(''MATLAB. Picture the Power.'');' };
%slide(1).code2={};
slide(1).text={
'欢迎您使用滤波器设计教学软件!',
'',
' 作为您的向导,我将带领您领略滤波器设计的过程。整个旅程分为若干',
'步骤,您在这里看到的是第一屏,即出发点。一“屏”就是量化的一个步骤',
'。每一屏所做的工作或为选择一种数字滤波器子类,或为进行参数输入,或',
'者输出相关的计算方法和中间结果。同时,在每一屏,您可以方便地通过“',
'上一页”、“下一页”、“重置”来向前向后翻屏、重改数据等。此外,通',
'过“演示”按钮,向导可以按照默认值自动设计滤波器,在演示过程中,您',
'可以随时停止演示,并手动继续设计。',
'',
' 现在,您将能设计出所需的数字滤波器了,开始吧,您不会后悔的!'};
slide(1).next=[2,2];
%========== Slide 2 ==========
%======choose Lp/Bp/Hp in AF==
%slide(2).ttl='';
slide(2).code1={'请你选择滤波器类型(LP/HP/BP):'};
%slide(2).code2={'xptext( ''>> a = [1 2 3 4 6 4 3 4 5]'', '' '', ''a ='', '' '', '' 1 2 3 4 6 4 3 4 5'' );' };
slide(2).text={
'首先, 您需要确定要设计的滤波器是什么类型的, 只有这样, 才能做到"有的放矢".',
'所以, 这之后的几个步骤都是用来确定您的设计目标. ',
'',
'低通, 高通和带通这样一种分类是基于滤波器的频率响应并在实际应用中滤波效果',
'而划分的. 但是您心里应该清楚, 我们最后设计出的滤波器是绝对不可能像理想的',
'那样具有刀切式的滤波效果, 那样的美梦是不可能实现的. 当然, 逼近理想的频率',
'响应效果越好越符合人们的愿望. 但同时, 这耗费的资源也越来越大. 所以, 您在',
'实际设计时, 需要权衡利弊, 做出合理的滤波器子类型的选择和参数的选择, 我们',
'今天就给您这样的一个实践机会, 您可以从现在就开始积累经验值啦!'};
slide(2).next=[1,0,0;3,0,0;dfOriginalIndex,dfOriginalIndex,dfOriginalIndex];
%========== Slide 3 ==========
%choose the AFLP original type
slide(3).ttl='模拟';
slide(3).code1={};
%'xptext(''>> b = a + 2'','' '', ''b ='', '' '', '' 3 4 5 6 8 6 5 6 7'' );' };
%slide(3).code2={};
slide(3).text={
' Now let''s add 2 to each element of our vector, ''a'', and store',
' the result in a new vector.',
'',
' Notice how MATLAB requires no special handling of vector',
' or matrix math.'};
slide(3).next=[4,0,0];
%=========temp================
for i=4:dfOriginalIndex-1
slide(i).ttl=num2str(i);
slide(i).next=[i+1,dfOriginalIndex];
%slide(i).code2={};
end;
%========== Slide 4 ==========
slide(4).code1={
'cla';
'a = [1 2 3 4 6 4 3 4 5];';
'b = a + 2;';
'plot(b)';
'grid' };
slide(4).text={
' Creating graphs in MATLAB is as easy as one command.',
' Let''s plot the result of our vector addition with grid lines.',
'',
' >> plot(b)',
' >> grid off'};
%slide(4).next=5;
%========== Slide 5 ==========
slide(5).code1={
'bar(b)';
'xlabel(''Sample #'')';
'ylabel(''Pounds'')' };
slide(5).text={
' MATLAB can make other graph types as well, with axis labels.',
'',
'>>bar(b)',
'>>xlabel(''Sample #'')',
'>>ylabel(''Pounds'')'};
%slide(5).next=6;
%========== Slide 6 ==========
slide(6).code1={
'plot(b,''*'')';
'axis([0 10 0 10])' };
slide(6).text={};
% ' MATLAB can use symbols in plots as well. Here is an',
% ' example using *''s to mark the points. MATLAB offers a',
% ' variety of other symbols and line types.',
% '',
% ' >> plot(b,''*'')',
% ' >> axis([0 10 0 10])'};
slide(6).code2={
'xptext(''>> B = A'''''','' '',''B ='','' '', '' 1 2 4'','' 2 5 10'','' 0 -1 -1'');' };
%slide(6).next=7;
%========== Slide 7 ==========
slide(7).code1={
'A = [1 2 0; 2 5 -1; 4 10 -1];',
'xptext( ''>> A = [1 2 0; 2 5 -1; 4 10 -1]'','' '',''A ='', '' '','' 1 2 0'','' 2 5 -1'','' 4 10 -1'' );' };
slide(7).text={
' One area in which MATLAB excels is matrix computation.',
'',
' Creating a matrix is as easy as making a vector, using',
' semicolons (;) to separate the rows of a matrix.'};
%slide(7).next=8;
%========== Slide 8 ==========
slide(8).code1={
'xptext(''>> B = A'''''','' '',''B ='','' '', '' 1 2 4'','' 2 5 10'','' 0 -1 -1'');' };
slide(8).text={
'We can easily find the transpose of the matrix ''A''.'};
%========== Slide 9 ==========
slide(9).code1={
'xptext(''>> C = A * B'','' '',''C ='','' '','' 5 12 24'','' 12 30 59'','' 24 59 117'');' };
slide(9).text={
' Now let''s multiply these two matrices together.',
'',
' Note again that MATLAB doesn''t require you to deal with',
' matrices as a collection of numbers. MATLAB knows when',
' you are dealing with matrices and adjusts your calculations',
' accordingly.'};
%========== Slide 10 ==========
slide(10).code1={
'xptext(''>> C = A .* B'','' '', ''C ='','' '','' 1 4 0'','' 4 25 -10'', '' 0 -10 1'' );' };
slide(10).text={
'Instead of doing a matrix multiply, we can multiply the,',
'corresponding elements of two matrices or vectors',
'using the .* operator.'};
%========== Slide 11 ==========
slide(11).code1={
'xptext( ''>> X = inv(A)'', '' '', ''X ='', '' '', '' 5 2 -2'', '' -2 -1 1'', '' 0 -2 1'' );' };
slide(11).text={
' Let''s find the inverse of a matrix ...'};
%========== Slide 12 ==========
slide(12).code1={
'xptext( ''>> I = inv(A) * A'', '' '', ''I ='', '' '', '' 1 0 0'', '' 0 1 0'', '' 0 0 1'' );' };
slide(12).text={
' ... and then illustrate the fact that a matrix times its inverse is',
' the identity matrix.'};
%========== Slide 13 ==========
slide(13).code1={
'xptext( ''>> eig(A)'', '' '', ''ans ='', '' '', '' 3.7321'', '' 0.2679'', '' 1.0000'' );' };
slide(13).text={
' MATLAB has functions for nearly every type of common',
' matrix calculation.',
'',
' There are functions to obtain eigenvalues ...'};
%========== Slide 14 ==========
slide(14).code1={
'xptext( ''>> svd(A)'', '' '', ''ans ='', '' '', '' 12.3171'', '' 0.5149'', '' 0.1577'');' };
slide(14).text={
' ... as well as the singular value decomposition.'};
%========== Slide 15 ==========
slide(15).code1={
'p = round(poly(A));';
'xptext( ''>> p = round(poly(A))'', '' '', ''p ='', '' '', '' 1 -5 5 -1'' );' };
slide(15).text={
' The characteristic polynomial of a matrix A is',
'',
' det(lambda*I - A)',
'',
' The "poly" function generates a vector containing the',
' coefficients of the characteristic polynomial.'};
%========== Slide 16 ==========
doi=dfOriginalIndex;
slide(doi).ttl='数字';
slide(doi).code1={
'请选择要设计的数字滤波器类型(FIR/IIR):'};
%'xptext( ''>> roots(p)'', '' '', ''ans ='', '' '', '' 3.7321'', '' 1.0000'', '' 0.2679'' );' };
%slide(doi).code2={};
slide(doi).text={
'IIR和FIR数字滤波器的分类时基于滤波器在时域的脉冲响应特性而划分的. 这是',
'两类截然不同的数字滤波器.',
'',
'IIR DF的设计出发点是借助于相应的模拟滤波器来设计. 这个途径比较省劲, 因',
'为模拟滤波器设计技巧已相当成熟, 有大量简单的公式和图表作为强大的工具后',
'盾, 因此设计起来相当方便简单, 且可以得到一封闭公式表示的设计结果. IIR时',
'域无限, 自然极点到处蔓延, 导致的结果是系统可能不稳定. 且IIR最大的问题是',
'它的非线性相位性.',
'',
'理想滤波器往往在频域是带限的, 对应于时域却是无限的, 显然是不可能实现的, ',
'FIR DF的设计思想就是通过对要求设计的频率响应(如理想低通滤波器)进行某种逼',
'近. FIR在时域有限, 所以是稳定可实现的. 且其最诱人的一点是其线性相位性.',
'',
'所以, IIR用于对相位要求不敏感的场合. FIR则用于对线性相位要求较高的场合.'};
slide(doi).next=[2,0;doi+1,doi+15;doi+1,doi+16;doi+1,doi+17];
%========== Slide 17 ==========
slide(doi+1).ttl='FIR';
slide(doi+1).code1={
'请你选择设计FIR DF的方法:'} ;
%slide(doi+1).code2={};
%'q = conv(p,p);',
%'xptext( ''>> q = conv(p,p)'', '' '', ''q ='', '' '', '' 1 -10 35 -52 35 -10 1'' );' };
slide(doi+1).text={
'用一个有限时域响应去逼近无限时域就是FIR方法的基本思路, 一般有两种方法:',
'',
'窗口法是直接在原无限的时域响应上截取有限的一段, 最容易想到的就是直接截',
'取, 这就是矩形窗法, 它产生的效果是最小平方意义上的对原信号的最佳逼近, ',
'且窗口长度越长, 误差越小. 为了减小过冲和欠冲(即增大阻带衰减), 采用了对',
'矩形窗加权的办法, 即窗函数, 代价是过渡带的加宽, 当然, 加权以后的设计方',
'法, 已经不再是最小逼近.',
'',
'频率采样在时域表现起来就是周期延拓. 对理想的带限的滤波器的频率采样, 就',
'是无限延伸的时域信号的周期延拓, 显然这就会带来一定程度的混淆. 所谓逼近,',
'就是在这里体现的. 即频率采样法的思路是用时域中有一定混淆的脉冲响应来逼',
'近没有混淆的理想情形. 在采样点上, 逼近出来的频响将于理想的严格一致, 其',
'它点是内插而来. 所以, 频率采样法是基于插值法的逼近方法.'};
slide(doi+1).next=[2,0;doi+2,doi+2;doi+3,doi+3;doi+4,doi+4];
%========== Slide 18 ==========
slide(doi+2).ttl='低通';
slide(doi+2).code1={'现在,请你输入你要用窗口法逼近的理想LPDF的参数:';'低通截止频率 Ws='};
slide(doi+2).text={
'该截止频率是要用FIR窗口法/频率响应法逼近的理想低通滤波器频率响应从"1"跳',
'变为"0"的临界频率. 要改变默认值(π/4), 则在输入框中输入需要的值即可, 值',
'应该在0到π之间. 其理想的频率响应相应的绘于该屏输入框下方. 在输入完毕后,',
'回车以表示确认, 同时, 下面的频率响应图也会应以更新到新的截止频率下的频响',
'图. 在这里, π用pi来表示, 如π/4输入0.25pi或0.25*pi, 当然也可以直接输入',
'π/4的值: 0.785. ' };
slide(doi+2).next=[doi+1;doi+5;doi+10];
%============Slide 19============
%=====doi+3======================
slide(doi+3).ttl='高通';
slide(doi+3).code1={'现在,请你输入你要用窗口法逼近的理想HPDF的参数:';'高通截止频率 Ws='};
%slide(doi+3).code2={};
slide(doi+3).text={
'该截止频率是要用FIR窗口法/频率响应法逼近的理想高通滤波器频率响应从"0"跳',
'变为"1"的临界频率. 要改变默认值(3π/4), 则在输入框中输入需要的值即可, 值',
'应该在0到π之间. 其理想的频率响应相应的绘于该屏输入框下方. 在输入完毕后,',
'回车以表示确认, 同时, 下面的频率响应图也会应以更新到新的截止频率下的频响',
'图. 在这里, π用pi来表示, 如π/4输入0.25pi或0.25*pi, 当然也可以直接输入',
'π/4的值: 0.785. ' };
slide(doi+3).next=[doi+1;doi+5;doi+10];
%============Slide 20============
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -