know signal frequency in matlab

Status
Not open for further replies.

30min

Newbie level 2
Joined
Sep 13, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
16
Hi,

I've problem in know signal frequency in matlab?
Is there any way to know that? any function to calculate it?
for example
Code:
t=-10:0.001:10;
a=sin(2*pi.*t);
what's the frequency of a?

best regards
 

MATLAB code do not provide information concerning to physical base that a vector is represented. This must be presumed when you modeled these equations.


+++
 

It just depends what the units of t are. If t is measured in seconds, then the sampling period is 0.001 seconds. Therefore, the sampling frequency is 1/0.001 = 1000Hz.

This means that the frequency of a is 1Hz. Each full cycle of a will comprise 1000 discrete samples.
 

If you want to know the frequency just having a look at the equation, then since:

y=A*sin(2*pi*f*t)

represent a sinewave of amplitude "A" and frequency "f", in your case the amplitude is 1 (the measurement unit depends from what you are modelling) and frequency 1 Hz (of course as said by weetabixharry "t" has to be in seconds).
If instead you meant a function that automatically understand that the amplitude is "A" and the frequency "f" then you have to use the FFT of y, then take the peak. In ordinate you'll have the amplitude while in abscissa you'll have the frequency. You have to provide to the FFT the sampling time (that is the step of t, in seconds, in your case 0.001)
In order to get the correct amplitude "A" (that is the peak amplitude) you have to multiply the amplitude read from the output of the FFT by a factor 2/N where N is the number of samples you provide to the FFT (the length of the vector "t")

If your signal is more complex than a simple sinewave the FFT will give you as many peak as the number of frequencies belonging to your signal (see Fourier analysis for details).
 

as said by weetabixharry "t" has to be in seconds
Sorry, I did not mean to imply that t must be in seconds. There is no requirement for t to be in seconds.
you have to use the FFT
The FFT is one option, but there are many other options. Which one is best for you depends on your requirements. For example, the FFT is rather useless if you have less than one complete cycle of the sine wave. The FFT can also suffer from poor resolution. So-called superresolution algorithms exist (such as the MUSIC algorithm), which are superior in this respect.
 

About "t" I just meant it has to be in seconds if you want the frequency directly in Hz.
I agree with you there are many methods that can be used rather than FFT, mainly for special cases and depending from requirements, however I thought that the question of 30min is quite basic, so he need a simple answer.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…