Here is a simple question. The next nested for loop creates an array of sine wave values.
N = 2^16; for m = 1:10; for i = 1:N sine(m,i) = sin(2*pi*i./(8*2^m)); end end
It seems that I would have to create this array without using for loops, but I tried various syntaxes and always got an error message. Thanks in advance for any ideas.
You can use bsxfunas follows:
bsxfun
sine = sin(bsxfun(@times, 2*pi*(1:2^16), 1./(8*2.^(1:10))' ));
Try the following:
ii = 1:2^16; m = [1./(2.^(1:10))].'% transpose prefactor = 2 * pi / 8; sine = sin(prefactor * m * ii);
A*B, a - , B - ncols , nkn. , m - ii .
A*B
m
ii
Try using ndgrid
ndgrid
N=2^16; [M, I] = ndgrid(1:10, 1:N); sine = sin(2*pi*I./(8*2.^M));