cconv.m
来自「Circular Convolution of two equal-length」· M 代码 · 共 44 行
M
44 行
function op = cconv(x,y)%CCONV N-point circular convolution%% op = CCONV(x,y) performs the N-point circular convolution% of vectors x and y. 'op' is returned as a row vector. x and y% must be vectors of equal lengths. %% See also CONV%% Peter Mash% pete@lightblueoptics.com% 17-Nov-2006Nx = length(x);Ny = length(y);% catch error - different lengthsif(Nx~=Ny) error('Vectors must be the same length in this version');end% catch error - x or y is a matrix not a vector[N M] = size(x);if((N<N*M) && (M<N*M)) error('x must be a vector')end[N M] = size(y);if((N<N*M) && (M<N*M)) error('y must be a vector')end% perform cyclic convolutionfor n=1:Nx op(n) = sum(x(1:Nx).*y(mod(n-1:-1:n-Ny,Ny)+1));end% output as a column vectorop = op.';% note, the same result may be more quickly achieved using:%% op = ifft(fft(x).*fft(y));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?