Functions > Signal Processing > Additional Transforms > Example: The Hartley Transform
  
Example: The Hartley Transform
Use the dht function to find the Hartley transform of signals.
The defining sum for the Hartley transform is analogous to the discrete Fourier transform sum.
Click to copy this expression
where N is the number of elements in the real data array x.
Sum of Sine Waves
Find the Hartley transform for a sum of sine waves and compare it with the magnitude of the complex Fourier transform.
1. Define the number of elements.
Click to copy this expression
Click to copy this expression
2. Use the sin function to define the input signal.
Click to copy this expression
Click to copy this expression
3. Plot the signal.
Click to copy this expression
4. Use the dht function to show the discrete frequencies represented in the two sine waves, and then use the center function to shift the DC component to the center.
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. Use the match and max functions to find the discrete frequencies at which the peaks occur, and mark one such point with a vertical and a horizontal marker.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
6. Use the dft and center functions to get and center the discrete Fourier Transform.
Click to copy this expression
7. Plot the absolute values of the DFT.
Click to copy this expression
Click to copy this expression
8. Use the match and max functions to find the discrete frequencies at which the peaks occur.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
The close relationship between the Hartley transform and the Fourier transform can be demonstrated by showing how to compute phase and magnitude from the Hartley transform. This can be done using a small data set.
Short and Noisy Signal
1. Define and plot a noisy input signal of 7 sample points.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Compute and center the discrete Hartley transform.
Click to copy this expression
3. Compute the odd and even parts of the discrete Hartley transform (these formulas assume an odd value of N).
Click to copy this expression
Click to copy this expression
4. Use the angle function to calculate the phase vector.
Click to copy this expression
5. Define the magnitude vector.
Click to copy this expression
6. Use the phase, phasecor, and center functions to create the phase vector.
Click to copy this expression
7. Use the augment function to compare the phase results to that obtained via the Fourier transform.
Click to copy this expression
The phase results agree.
8. Use the dft and center functions to create the magnitude vector.
Click to copy this expression
9. Use the augment function to compare the magnitude results to that obtained via the Fourier transform.
Click to copy this expression
The magnitude results agree.
For a thorough treatment of the Hartley transform and its applications, see Ronald Bracewell's book The Hartley Transform (Oxford University Press).