⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t3question3_ii.m

📁 SOUNDSC(Y,...) is the same as SOUND(Y,...) except the data is scaled so that the sound is played a
💻 M
字号:
% Define filter
B = [1 -0.5]; % coefficients b_k
A = [1 0.75]; % coefficients a_k

% Define inputs
n=[0:9]; %
x1 = [1, zeros(1,9)]; % unit impulse input
x2 = ones(1,10); % unit step input (first 10 samples)
x3 = [1, 0, 3, 2, 1, 0, 0, 0, 0, 0]; % third signal given in question

% Compute outputs
y1 = filter(B,A,x1); % output for x1

% alternatively we can use function impz to compute impulse response as follows
% [y1, n1] = impz(B,A,10);
% another alternative is to use function impulse as follows
% sys = filt(B,A,1); % defines the filter as an LTI system
% [y1, n1] = impulse(sys,9);

y2 = filter(B,A,x2); % output for x2

% alternatively we can use function stepz to compute step response as follows
% [y2, n2] = stepz(B,A,10);
% another alternative is to use function step as follows
% sys = filt(B,A,1); % defines the filter as an LTI system
% [y2, n2] = step(sys,9);

y3 = filter(B,A,x3); % output for x3

% Plot the inputs and corresponding outputs
subplot(3,2,1);
stem(n,x1,'filled');
xlabel('n \rightarrow');
ylabel('x_1[n] \rightarrow');
grid;
set(gca,'XTick',n);
subplot(3,2,2);
stem(n,y1,'filled');
xlabel('n \rightarrow');
ylabel('y_1[n] \rightarrow');
grid;
set(gca,'XTick',n);
subplot(3,2,3);
stem(n,x2,'filled');
xlabel('n \rightarrow');
ylabel('x_2[n] \rightarrow');
grid;
set(gca,'XTick',n);
subplot(3,2,4);
stem(n,y2,'filled');
xlabel('n \rightarrow');
ylabel('y_2[n] \rightarrow');
grid;
set(gca,'XTick',n);
subplot(3,2,5);
stem(n,x3,'filled');
xlabel('n \rightarrow');
ylabel('x_3[n] \rightarrow');
grid;
set(gca,'XTick',n);
subplot(3,2,6);
stem(n,y3,'filled');
xlabel('n \rightarrow');
ylabel('y_3[n] \rightarrow');
grid;
axis([0 10 -3 4]);
set(gca,'XTick',n);
set(gca,'YTick',[-3:4]);
gtext('Response for filter (ii)');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -