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; |
|
circular conv
Started by ●March 28, 2003
Reply by ●March 31, 20032003-03-31
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); _____________________________________ Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. _____________________________________ About this discussion group: To Join: To Post: To Leave: Archives: http://www.yahoogroups.com/group/matlab More DSP-Related Groups: http://www.dsprelated.com/groups.php3 |