% Function: % fhp - calculate the first Fourier harmonic projection of a give data set. % Input: % data - m x n numerical matrix % Output: % out - m x 2 matrix containing the real and imaginary parts % of the first Fourier harmonic projection % Usage: % proj = fhp(inputdata); % % Date: 2/27/2006 function out = fhp(data) [m n] = size(data); % calculate the input data dimension outR = zeros(m, 1); % real part outI = zeros(m, 1); % imaginary part theta = (-2 * pi) / n; % incremental angel % for every data point, do the projection for i=1:m rowdata = data(i, :); x = 0.0; y = 0.0; % take the first Fourier harmonic projection for j=1:n x = x + data(i,j) * cos(theta * (j-1)); y = y + data(i,j) * sin(theta * (j-1)); end outR(i) = x; % real part outI(i) = y; % imaginary part end % combine real and imaginary parts into one matrix out = [outR outI];