Douglas Gleichman's Projects
A C++/Qt clone of the popular 2048 game
Basic example of using GLFW + Imgui
Biquad Filter Design Tool
This is a demonstration to show how to calculate power spectra and power spectral densities in real time. We calculate power spectra directly using DFT (or FFT). There are many conventions for DFT. We use the convention is the paper “Analysis of Relationship between Continuous Time Fourier Transform (CTFT), Discrete Time Fourier Transform (DTFT), Fourier Series (FS), and Discrete Fourier Transform (DFT)”. We calculate power spectral and power spectral densities using the MATLAB function periodogram. We could use pwelch to replace periodogram. The only difference between periodogram and pwelch is that pwelch supports segmentation and averaging, whereas periodogram does not. For the sake of simplicity, we only use periodogram in this demonstration. One will see that the power spectrum is equal to the square of the absolute value of DFT. When manually calculating a power spectrum, the hard job is to calculate the argument vector, or the independent variable vector, which is a frequency vector in this case. The frequency vector depends on the representation of the power spectrum. In general, there are three ways to represent a power spectrum for a real valued signal. One way is called “two-sided”. This is the default way to represent a power spectrum with DFT. However, this representation is not intuitive. The frequency vector is calculated by f = (0:N-1)/T, where T is the time period (or duration) of the input signal. When using the MATLAB function, periodogram, one can specify this representation using “onesided”. A more natural way is to use a centered representation. In this case, the frequency 0 is centered in the spectrum. If the number of spectral lines (equal to the number of input points) is odd, then we have a unique centered representation. If the number of spectral lines is even, then we have a problem. Let us assume that we use a zero-based index for spectral lines. The spectral line 0 is the DC component, and it is put in the f = 0 location. However, the spectral line N/2 can be placed on the positive side or the negative side. Different conventions may have different placements. In order to obtain this representation, one has to shift the FFT result. One way is to use the MATLAB function fftshift. This MATLAB function always places the N/2 spectral line on the negative side. When using the MATLAB function, periodogram, one can specify this representation using “centered”. It should be noted that the MATLAB function, periodogram, usually puts the N/2 spectral line on the positive side. The last way to represent a power spectrum is the one-sided representation. For this representation, we need to combine negative frequency components and positive components together, and we only show the positive half as well as the DC component. The combination process depends the evenness or oddness of the number of spectral lines. If the number of spectral lines is odd, we can simply combine spectral lines 1 to (N-1)/2 with spectral lines (N+1)/2 to N-1. The spectral line 0 is left untouched. If the number of spectral lines is even, we need to combine spectral lines 1 to N/2-1 with lines N/2+1 to N-1. The spectral lines 0 and N/2 are left untouched. In order to obtain this representation, one has to manually carry out the combination process. The combination process is different depending on the evenness or oddness of the number of spectral lines. When using the MATLAB function, periodogram, one can specify this representation using “onesided”. In this demonstration, we only use the centered representation. Hence, there is no need to do combination. One can see that the sum of all power spectral lines in a power spectrum is equal to the power of the input signal. One can alternatively calculate the PSD with the periodogram function by specifying “psd” instead of “power”. In fact, the PSD obtained by periodogram is an equivalent noise power spectral density. One can see that ENPSD is related to PS by a factor of 1/T. It should be noted that a power spectrum is a discrete sequence, or a discrete continuous-argument function, whereas an ENPSD is a non-discrete continuous argument function. For emphasize this, I used stem for power spectra and plot for ENPSD. In this demonstration, we start with a sinusoidal signal with various parameters. We then proceed with an actual audio signal.
Config files for my GitHub profile.
Doug Gleichman GitHub Website
Repository for Matlab code Implementation of EKF and UKF for 9-D state space equation
A visual Haskell
This is a Kalman filter used to calculate the angle, rate and bias from from the input of an accelerometer/magnetometer and a gyroscope.
This repository contains example files organized by chapters in Mastering Algorithms with C, by Kyle Loudon
A copy of the C code from Free small FFT in multiple languages Project Nayuki
Qt5 example calculator
A simple Matlab example of sensor fusion using a Kalman filter
This is the spreadsheet example from C++ GUI Programming with Qt 4 by Blanchette and Summerfield Chap 4
Lightweight C/C++ Extended Kalman Filter with Python for prototyping
My web examples and practice