function out=cossig(f,N,fs,ph);

%
% COSSIG(F,N,FS) calculates a cosine-signal with the frequency F, 
% the number of samples N for the sampling frequency FS.
%
% COSSIG(F,N,FS,PH) additionally considers the phase PH of the cosine 
% (in rad). Use ph=-pi/2 for a sine instead of cosine.

% Piotr Majdak


if ~exist('ph','var')
  ph=0;
end
dTH=2*pi*f/fs;
TH1=ph:dTH:2*pi*N*f/fs-dTH+ph;
out=cos(TH1);

