% costas_init.m -- Matlab script for use with costas_demo.mdl
% that sets up parameters for a Hilbert transform operation (or -90
% degree phase shift at all frequencies).
%
% Rich Kozick, Spring 2001

% This program should be run from matlab5 before running the costas_demo.mdl
% in Simulink.  Parameters can be changed in this file to set an
% appropriate sampling rate, etc.

N = 30;		% Order of Hilbert transform digital filter
		% (actual order is N+1)

Ts = 0.005;	% Sampling interval for the digital filter

% Now design the Hilbert transform digital filter.
% The filter will have -90 degree phase shift for frequencies
% in the range 0.1*fs/2 to 0.9*fs/2, where fs = 1/Ts.

Hilb = remez(N, [.1 .9], [1 1], 'Hilbert');

% Also need a Delay of N/2, since the Hilbert transform filter
% has a delay in order to make it causal!

Delay = [zeros(1, N/2), 1];
