📄 shiyan2.m
字号:
%实验二:卷积定理
%陈友兴
x=[3 0 2 1 3]; %原始序列
y=[3 0 2 1 3];
%直接计算圆周卷积或线性卷积
z=conv(x,y);
figure(1),subplot(311),stem(x);axis([1 8 0 4]);
subplot(312),stem(y);axis([1 8 0 4]);
subplot(313),stem(z);axis([1 8 0 30]);
%利用FFT计算
N=10;%N=8时
x1=[x zeros(1,N-length(x))];
y1=[y zeros(1,N-length(y))];
X1=fft(x1);
Y1=fft(y1);
Z1=X1.*Y1;
z1=ifft(Z1);
figure(2),
subplot(321),stem(x1);
subplot(322),stem(real(X1));
subplot(323),stem(y1);
subplot(324),stem(real(X1));
subplot(325),stem(z1);
subplot(326),stem(real(Z1));
N=5;%N=5时
x2=[x zeros(1,N-length(x))];
y2=[y zeros(1,N-length(y))];
X2=fft(x2);
Y2=fft(y2);
Z2=X2.*Y2;
z2=ifft(Z2);
figure(3),
subplot(321),stem(x2);
subplot(322),stem(real(X2));
subplot(323),stem(y2);
subplot(324),stem(real(X2));
subplot(325),stem(z2);
subplot(326),stem(real(Z2));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -