property4.m
来自「用dsp解压mp3程序的算法」· M 代码 · 共 40 行
M
40 行
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% property4 - Program for showing Circular convolution
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
x = [1 0.8 0.6 0.4 0.2 0.1 0.3 0.5];
h = [1 0.5 0.3 0.1];
h = [h zeros(1,4)]; % zero-padding to length of 8
% In frequency domain
X = fft(x,8);
H = fft(h,8);
Y = X.*H;
y = ifft(Y,8);
% In time domain
N= 8;
m = [0:1:N-1];
x = x(mod(-m,N)+1);
X_m = zeros(N,N);
for n = 1:1:N
p = [0:1:N-1];
p = mod(p-(n-1),N);
X_m(n,:) = x(p+1);
end
y_cc = X_m*h';
% Plot results
figure;
subplot(211);stem(y),title('Circular Convolution using Freq. domain');
subplot(212);stem(y_cc),title('Circular Convolution using Time domain');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?