%% cossinmat3 %% function that returns the matrix to produce "Fourier" cosine-sine coefficients %% this function is the same as cossinmat2 except the columns are grouped by frequency function A = cossinmat3(N) % test of even or odd % even = 1 if N is even and even =0 if N is odd. Note the use of ~. even = ~rem(N,2); n = fix((N-1)/2); %Construct column of sample points. Note the use of ' t = (2*pi/N)*(0:1:(N-1))'; % the following loops use vectorized function evaluation % % the matrix is created two coulns at a time A = ones(N,1); for j = 1:n A = [A,cos(j*t),sin(j*t)]; end; if even A = [A, cos((N/2)*t)]; end;