① 単位ステップ列 u[n] と u[n+7]
clear ; clc; close all;
% Generate a vector from -10 to 20
n = -10:20;
% Generate the unit sample sequence
x = [zeros(1,10) 1 zeros(1,20)];
% Plot
subplot(1,2,1);
stem(n,x); % u[n]
xlabel('n');ylabel('\delta[n]');
M = 7;
xd = [zeros(1,10-M) 1 zeros(1,20+M)];
subplot(1,2,2);
stem(n,xd); % u[n+7]
xlabel('n');ylabel('\delta[n+7]');
② 複素指数列を生成する左と右の部分グラフを使用して、それぞれ列の実部と虚数部を描画します
% Generation of a complex exponential sequence
clear ; clc; close all;
c = 0.2 + 3 * i;
K = 1.5;
n = 0 : 15;
x = K * exp(c * n);
subplot(2,1,1);
stem(n,real(x));
xlabel('n');ylabel('Amplitude');
title('Real part');
subplot(2,1,2);
stem(n,imag(x));
xlabel('n');ylabel('Amplitude');
title('Imaginary part');
③実指数数列の生成と描画
% Generation of a real exponential sequence
clear ; clc; close all;
n = 0 : 15;
a = 0.8;
K = 2;
x = K * a.^n;
stem(n,x);
xlabel('n');ylabel('Amplitude');
④ 正弦波列の生成と描画
% Generation of a sinusoidal sequence
clear ; clc; close all;
n = 0:49;
A = 2.5;
w = 0.16 * pi;
phase = pi / 2;
x = A * cos( w * n + phase);
clf;
stem(n,x); % Plot the generated sequence
axis([0 50 -3 3]);
grid;
title('Sinusoidal Sequence');
xlabel('n');
ylabel('Amplitude');
⑤ 产生序列 x[n] = {1,2,3,4}, 0 ≤ n ≤ 3 y[n] = {3,4,5,6}, 0 ≤ n ≤ 3
w1[n] = x[n] + y[n] 0 ≤ n ≤ 3 w1[n] = x[n] * y[n] 0 ≤ n ≤ 3
clear ; clc; close all;
n = 0 : 3;
x = [1 2 3 4];
y = [3 4 5 6];
w1 = x + y;
w2 = x .* y;
subplot(2,2,1); stem(n,x);
xlabel('n');ylabel('x[n]'); title('x[n]序列');
subplot(2,2,2); stem(n,y);
xlabel('n');ylabel('y[n]'); title('y[n]序列');
subplot(2,2,3); stem(n,w1);
xlabel('n');ylabel('w1[n]'); title('w1[n]序列');
subplot(2,2,4); stem(n,w2);
xlabel('n');ylabel('w2[n]'); title('w2[n]序列');
⑥ シーケンス x[n] = {1,2,4,-5,-2}, -2 ≤ n ≤ 2 を生成し、パリティを計算して描画します
実数シーケンスは、偶数部分と奇数部分 の合計として表現できます。
clear ; clc; close all;
n = -2 : 2;
x = [1 2 4 -5 -2];
m = n + 3;
ev = (x(m) + x(6 - m)) / 2 ;
od = (x(m) - x(6 - m)) / 2 ;
subplot(3,1,1); stem(n,x);
xlabel('n');ylabel('x[n]'); title('x[n]序列');
subplot(3,1,2); stem(n,ev);
xlabel('n');ylabel('xev[n]'); title('x[n]偶部序列');
subplot(3,1,3); stem(n,od);
xlabel('n');ylabel('xod[n]'); title('x[n]奇部序列');
⑦ x[n] と h[n] の線形畳み込み y[n] を計算します。
線形時不変離散システムの場合、出力シーケンスは、入力シーケンスとインパルス応答 (単位インパルス応答) の線形畳み込みです。
clear ; clc; close all;
n = 0 : 14;
x = (-1).^n;
m = 0 : 7;
h = cos(0.25 * pi * m);
y = conv(h,x)
n = 0:21;
stem(n,y);
xlabel('n');
ylabel('y[n]');
title('Output Obtained by Linear Convolution');
grid;
⑧ 正弦波形を重ね合わせた範囲内の連続波形
clear ; clc; close all;
t = 0 : 10^(-6) : 6*10^(-3);
xa = cos(5000*pi*t) + 4*sin(2000*pi*t).*sin(3000*pi*t);
plot(t,xa);grid
xlabel('Time, sec');
ylabel('Amplitude');
title('Continuous-time signal x_{a}(t)');