function fh=Sub_dht(f,m,usg)
% Calculates fh, the discrete Hilbert Transform of f
% This function takes in a vector containing the real or the imaginary
% part of a discrete transfer function f = [f1;f2;f3;...;fnumfreq].
% It uses those points to calculate fh = [fh1;fh2;fh3;...;fhnumfreq].
% It calculates these values according to this function:
% fhk = 2/pi * sum(n odd) fn/(k-n), k even
% 2/pi * sum(n even) fn/(k-n), k odd
% m = number of frequency points
% usg = scaling factor
% Here is where you write the code to implement the discrete Hilbert
% transform
% Everything below is a possible way to implement this function. Feel free
% to ignore it completely in favor of your own method.
% pre-allocation of memory for fh
fh = 0.*f; % creates fh to be same size as f but makes every entry = 0
for k = 1:m
parity_k = mod(k,2); % =1 when k is odd
% NOTE: mod(m,2) = 1 if m is odd. This might be useful.
if(parity_k == 1)
% fhk = 2/pi * sum(n even) fn/(k-n), k odd
% you write this; you will probably want a for loop
% for n = 2:2:m % executes for loop for n = 2,4,6,...
else
% fhk = 2/pi * sum(n odd) fn/(k-n), k even
% you write this; you will probably want a for loop
% for n = 1:2:m % executes for loop for n = 1,3,5,...
end
fh(k) = -usg*result; % result is value calculated in if/else statements
% the - above is just to fit with my convention from the causality file
end