My snipet code have 3 harmonics, second's amplitude is maximum, but abs(fft(X)) returns first as maximum. I use MATLAB R2022a.

2 views (last 30 days)
In Xn first harmonic's amplitude is 170, second's 220, and third's 150. But abs(fft(Xn) returns maximum first's. Thanks in advance. It is executing in R2022a version.
SampFreq = 16000;
Segm = 1:2048;
Pitch = 45;
FirstHarmAngles = Pitch*2*pi/SampFreq*Segm+1.9*pi;
SinFirstHarmAngles = sin(FirstHarmAngles);
SecondHarmAngles = Pitch*2*2*pi/SampFreq*Segm+2.9*pi;
SinSecondHarmAngles = sin(SecondHarmAngles);
ThirdHarmAngles = Pitch*3*2*pi/SampFreq*Segm+0.3*pi;
SinThirdHarmAngles = sin(ThirdHarmAngles);
Xn = 170*SinFirstHarmAngles+220*SinSecondHarmAngles+150*...
SinThirdHarmAngles;
ABS = abs(fft(Xn))
ABS = 1×2048
1.0e+05 * 0.0359 0.0414 0.0581 0.0907 0.1634 0.4385 1.6552 0.4040 0.3079 0.3324 0.4876 1.3711 1.5150 0.5278 0.3604 0.3266 0.4070 1.4252 0.4674 0.1809 0.1132 0.0852 0.0703 0.0610 0.0546 0.0499 0.0461 0.0431 0.0405 0.0383
plot(ABS(1:50))

Accepted Answer

Jeffrey Clark
Jeffrey Clark on 14 Sep 2022
@Georges Theodosiou, you don't have enough samples to easily interpret the abs(fft), if you change Segm = 1:2048 to use 16384 you get
Your plot from 2048 samples shows that the second peak contains the energy over a wider frequency range. Instead of increasing the number of samples this can be captured by increasing the fft n-point DFT by adding 16384 as the DFT size e.g., ABS = (abs(fft(Xn,16384))) which results in
Please see Fast Fourier transform - MATLAB fft (mathworks.com) and its examples for more information.
  5 Comments
Georges Theodosiou
Georges Theodosiou on 28 Sep 2022
@Jeffrey Clark. Dear gentlemen, please le me express you my sincere gratitude for your kindness to help me, and tell you I'm beginner in DSP and MATLAB, also homeless (in France, though Greek). I get internet access in municipal Libraries and social Centers. My project, metrw-pitch, demands that user could see on screen his voice's pitch at least 8 times per second. Regards.

Sign in to comment.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!