Technical discussion about Matlab and issues related to Digital Signal Processing.
|
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); K = 0:Nx+Nh-4; |
|
|
|
That's right, in circular convolution the resultant length is the size of the longest vector. You can test your results by using the circular convolution matrix, this link may help you: http://cnx.rice.edu/content/m10459/latest/ Regards, Claudio U. V. ----- Original Message ----- From: harima To: matlab Sent: Sunday, March 30, 2003 2:28 AM Subject: [matlab] circular conv 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); Yahoo! Groups Sponsor ADVERTISEMENT _____________________________________ /groups.php3 Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. |