📄 ip_01_07.m
字号:
% MATLAB script for Illustrative Problem 7, Chapter 1.echo ondf=0.01; % Freq. resolutionfs=5; % Sampling frequencyts=1/fs; % Sampling intervalt=[-5:ts:5]; % Time vectorx=zeros(1,length(t)); % Input signal initiationx(16:26)=t(16:26)+2;x(27:31)=2*ones(1,5);x(32:41)=2+2*cos(0.5*pi*t(32:41));x(42:46)=2*ones(1,5);% Part 1[X,x1,df1]=fftseq(x,ts,df); % Spectrum of the inputf=[0:df1:df1*(length(x1)-1)]-fs/2; % frequency vectorX1=X/fs; % Scaling% Part 2% Filter transfer functionH=[ones(1,ceil(1.5/df1)),zeros(1,length(X)-2*ceil(1.5/df1)),ones(1,ceil(1.5/df1))]; Y=X.*H; % Output spectrumy1=ifft(Y); % Output of the filter% Part 3% LTI system impulse responseh=[zeros(1,ceil(5/ts)),t(ceil(5/ts)+1:ceil(6/ts)),ones(1,ceil(7/ts)-ceil(6/ts)),zeros(1,51-ceil(7/ts))];y2=conv(h,x); % Output of the LTI systempause % Press a key to see spectrum of the inputplot(f,fftshift(abs(X1)))pause % Press a key to see the output of the lowpass filterplot(t,abs(y1(1:length(t))));pause % Press a key to see the output of the LTI systemplot([-10:ts:10],y2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -