To understand, print the first few samples from the FFT result and observe that they are not absolute zeros (they are very small numbers in the order.
Even a small floating rounding off error will amplify the result and manifest incorrectly as useful phase information ( read how a computer program approximates very small numbers). The phase spectrum is noisy due to fact that the inverse tangents are computed from the of imaginary part to real part of the FFT result. Stem(f,abs(X)) %magnitudes vs frequencies SampleIndex = -N/2:N/2-1 %ordered index for FFT plotį=sampleIndex*df %x-axis index converted to ordered frequencies The amplitude spectrum is obtainedįor obtaining a double-sided plot, the ordered frequency axis (result of fftshift) is computed based on the sampling frequency and the amplitude spectrum is plotted. The FFT function computes the complex DFT and the hence the results in a sequence of complex numbers of form. Extract amplitude of frequency components (amplitude spectrum) A scaling factor was used to account for the difference between the FFT implementation in Matlab and the text definition of complex DFT.
Ansys 11 magnitude code#
In the code above, is used only for obtaining a nice double-sided frequency spectrum that delineates negative frequencies and positive frequencies in order. X = 1/N*fftshift(fft(x,N)) %N-point complex DFT
No need to worry about loss of information in this case, as the 256 samples will have sufficient number of cycles using which we can calculate the frequency information. In this case, only the first time domain samples will be considered for taking FFT. We can simply use a lower number for computing the FFT. However, we can choose a reasonable length if we know about the nature of the signal.įor example, the cosine signal of our interest is periodic in nature and is of length samples (for 2 seconds duration signal). The length of the transformation should cover the signal of interest otherwise we will some loose valuable information in the conversion process to frequency domain. The FFT function computes -point complex DFT. Lets represent the signal in frequency domain using the FFT function. Represent the signal in frequency domain using FFT X=A*cos(2*pi*fc*t+phi) %time domain signal with phase shift Phi = phase*pi/180 %convert phase shift in degrees in radians Phase=30 %desired phase shift of the cosine in degreesįs=32*fc %sampling frequency with oversampling factor 32 I have chosen a oversampling factor of so that the sampling frequency will be, and that gives samples in a seconds duration of the waveform record.
In order to represent the continuous time signal in computer memory, we need to sample the signal at sufficiently high rate (according to Nyquist sampling theorem). Discrete-time domain representationĬonsider a cosine signal of amplitude, frequency and phase radians (or ) Wireless Communication Systems in Matlab, ISBN: 978-1720114352 available in ebook (PDF) format (click here) and Paperback (hardcopy) format (click here).
This article is part of the book Digital Modulations using Matlab : Build Simulation Models from Scratch, ISBN: 978-1521493885 available in ebook (PDF) format (click here) and Paperback (hardcopy) format (click here)
Ansys 11 magnitude how to#
In this post, I intend to show you how to obtain magnitude and phase information from the FFT results. In the previous post, Interpretation of frequency bins, frequency axis arrangement (fftshift/ifftshift) for complex DFT were discussed.