%% Ncossinmat4 %% function that returns the matrix to produce "Fourier" cosine-sine coefficients %% this function is the same as Ncossinmat and Ncossinmat2 function A = Ncossinmat3(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 matrix of sample points. Note the use of ' t = (2*pi/N)*(0:1:(N-1))'; jt = t*(1:n); % the sytement uses vectorized calculation on an entire matrix A = ones(N,1); A = [A,cos(jt)]; if even A = [A, cos((N/2)*t)]; end; A = [A,sin(jt)];