On Thursday, July 26, 2012 5:04:24 PM UTC-4, Brandon wrote: > It's been some time since I've used Matlab, but I need to vectorize the following code for performance reasons. I'm getting caught up on the square matrix R. I understand the concept of replicating vectors to form arrays using repmat() or multiplying vectors by ones(), but I can't wrap my head around this one, thanks. > > <SNIP> > N = 4; > angle_deg = 0; > angles = -180:0.1:180; > g = zeros(size(angles, 2), 1); > for k = 1:length(angles) > theta = angles(k); > % [N x 1] > n = (0:N-1).'; > % [N x 1] > x = exp(-1j*pi*n*sin( (theta-angle_deg)*pi/180)); > % [N x N] > R = (x * x'); > % [N x 1] > w = ones(N,1)/N; > % [1 x N] > wh = w'; > % [1 x 1] = [1 x N]*[N x N]*[N x 1] > tmp = wh * R * w; > % [K x 1] > g(k) = tmp; > end % for k = 1:length(angles) > </SNIP>
Ok weird I must have had a typo or pasted incorrectly. It looks fine now. I don't quite understand the methodology you applied to implement it however. Could you describe the process? Thanks.