How to plot harmonic components of a sine wave

I have a Sine wave signal as a column vector (this Sine signal was generated from another software 'LabVIEW' and then imported to Matlab and saved as a column vector). I want to find the magnitudes of specific harmonic components (such as 3rd and 5th harmonic) of this signal. At first I have tried to use the 'fft' function that converts my time domain signal to the frequency domain. This plots (barplot) frequency Vs. magnitude of the Sine signal. But, I want to plot(barplot) Harmonic order (X axis) Vs. magnitude (Y-axis) and see for example the magnitude of the 3rd harmonic component of the signal. I must be able to extract the value of H (harmonic order) which is not possible from the fft plot. I have attached here the .m file I am working on. I am not attaching the 'Sine' wave as it is okay if you use any sine wave with harmonics. I am more interested to know the plotting method to see harmonic orders with magnitudes (sample picture also attached).
Thanks a lot for your help. I really appreciate.

댓글 수: 7

Hi Maruf,
One question, is it possible to spot harmonics in a pure sin way at all?!
dpb
dpb 2015년 6월 3일
Not if there aren't any, no... :)
Maruf
Maruf 2015년 6월 3일
Hi Salaheddin,
Thank you for your question. Theoretically, even if the sine wave is pure, we should get the full amplitude at H=1 (harmonic order 1). Therefore, if we plot it, we should see only one peak at H=1. I hope that answers your question.
Thank you
Maruf,
That was a rhetorical question.
If you use fft you can observe the single ton frequency, however I don't think if you can extract any harmonics out of that?! What are you really after?!
Maruf
Maruf 2015년 6월 3일
The Sine curves that I am acquiring will be from a variable speed drive and it will definitely have harmonics. I am just trying out the coding first with a normal sine wave. If I am able to plot it with this and get the magnitude at H=1, then afterwards I shall replace the original curves from the VSD and acquire all the magnitudes in H=1 to H=n :)
Im doing DC to AC converter without using of filter, and i got 22% of THD . and i need to reduce the harmonics any one can help me to do..
You can add a capacitor to the output of the inverter, also, try using a unipolar PWM.

댓글을 달려면 로그인하십시오.

 채택된 답변

dpb
dpb 2015년 6월 3일
To plot versus the harmonic number you first must determine what the fundamental frequency of the signal is (either in Hz transforming the axes based on sample rate used or simply as the position number in the transform vector) . Once you have that, then the harmonics are at the ratios of that location accounting, of course, for rounding in that it's unlikely excepting for made-up inputs that the frequency of the signal will exactly match the frequency binning.
The PSD is generally easier than the straight FFT; see the
doc fft
for an example of building and normalizing a time history to a PSD in frequency domain.

댓글 수: 3

Maruf
Maruf 2015년 6월 3일
Dear dqb,
I know my signal frequency (50 Hz- system frequency). So if I understand your suggestion correctly, then I should do some kind of an axis transformation where I put H=1,2,3...,n as X axis and some how bring the magnitudes of 50,100,150,,,n*50 Hz components at the location of H=1,2,3,....n. If that is the case, then can you please suggest me a way for this kind of an axis transformation?
Thank you so much for your help.
As noted above, if you have a given sampling frequency Fs and length of the fft, NFFT, then
f = Fs/2*linspace(0,1,NFFT/2+1);
is the frequency associated with the (one-sided) PSD. For a given base frequency F, then
fHar=f/F; % Standardize to harmonic reference
The n_th_ harmonic will be at the bin nearest the locations n*fix(fHar)==n*fHar; as noted unless you fix the sampling rate and times precisely there won't necessarily be a frequency bin at, say, 50 Hz identically.
Maruf
Maruf 2015년 6월 4일
Thanks a lot :) it works

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Honglei Chen
Honglei Chen 2015년 6월 3일

0 개 추천

You can use thd for this, although it's not in the bar plot. But once you have the information, you can plot it yourself.

카테고리

질문:

2015년 6월 3일

댓글:

2020년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by