GithubHelp home page GithubHelp logo
Douglas Gleichman photo

dmgleichman Goto Github PK

followers: 2.0 following: 8.0 repos: 17.0 gists: 0.0

Name: Douglas Gleichman

Type: User

Company: Consultant

Bio: Embedded Systems and Software Engineering Hardware/Software Design Motor/Motion Control Real-time Signal Processing DSP, FPGA, Microcontrollers Electronics

Location: California

Douglas Gleichman's Projects

2048 icon 2048

A C++/Qt clone of the popular 2048 game

demonstration-dft-ps-psd icon demonstration-dft-ps-psd

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.

kalmanfilter icon kalmanfilter

This is a Kalman filter used to calculate the angle, rate and bias from from the input of an accelerometer/magnetometer and a gyroscope.

nayuki_fft_c icon nayuki_fft_c

A copy of the C code from Free small FFT in multiple languages Project Nayuki

sensorfusion icon sensorfusion

A simple Matlab example of sensor fusion using a Kalman filter

spreadsheet icon spreadsheet

This is the spreadsheet example from C++ GUI Programming with Qt 4 by Blanchette and Summerfield Chap 4

tinyekf icon tinyekf

Lightweight C/C++ Extended Kalman Filter with Python for prototyping

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.