DSPRelated.com
Forums

circular conv

Started by harima March 30, 2003
Hi there,

             Ive a doubt in finding circular convolution of two unequal sequences in MATLAB. Should the resultant length be equal to the highest of the given two vectors.

            Ive written a code for it but not sure about its result.

Hope there would b some to help me. If neone have still optimised code, do post it.

Thanks,
Hari.

x = [1 1 1 1 2 1];
h = [1 1 2 1];
Nx = length(x);
Nh = length(h);
N = max(Nx,Nh);
x = [x zeros(1,N-Nx)];
h = [h zeros(1,N-Nh)];

m = 0:1:N-1;
M = mod(-m,N)
h = h(M+1)

for n = 1:1:N
    m = n-1;
    p = 0:1:N-1;
    q = mod(p-m,N)
    hm = h(q+1)
    H(n,:) = hm
end
Y = x*H'

k = 0:N-1;
subplot(4,4,1);
stem(k,Y);
subplot(4,4,2);
C = conv(x,h);