electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

How can I calculate the period of this signal?


Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> How can I calculate the period of this signal?
Author Message
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post28 Sep 2007 13:47   

How can I calculate the period of this signal?


I want to calculate the peiod of this signal

How can I calculate the period of this signal?

the sampling frequency is 369hz?
how can i calculate it's period?



Sorry, but you need login in to view this attachment

Back to top
salam2000



Joined: 24 Jul 2006
Posts: 88
Helped: 12


Post28 Sep 2007 14:04   

Re: How can I calculate the period of this signal?


get FFT from this signal, Then the maximum amplitude is period, also you can use from pwelch in Matlab and set your sampling frequency in it to find max of it.
Back to top
scintillatingstuffs



Joined: 04 Jun 2006
Posts: 30
Helped: 4


Post28 Sep 2007 16:30   

Re: How can I calculate the period of this signal?


It is best if u can form an appropriate idea by taking the data tip marker from matlab, find the separation between 2 points tat are similar and divide it by 369 Hz!!!
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post28 Sep 2007 20:28   

Re: How can I calculate the period of this signal?


what is the relation between getting FFT from a signal and obtain the period of the signal???? Shocked Shocked Shocked
are you sure?
and how can pwelch canhelp me?could you explain it?
thanks.
Back to top
rakesh_vnit



Joined: 04 Sep 2007
Posts: 75
Helped: 10
Location: india


Post28 Sep 2007 21:30   

Re: How can I calculate the period of this signal?


hey...
the period of the signal is just the inverse of the freq of the signal. so, by takin the fft u would get the freq domain description of the signal from which u can find the freq of ur signal. now by takin the inverse of it u will come out wid the period of u signal...
why were u so amazed abt that idea?????
Back to top
Google
AdSense
Google Adsense




Post28 Sep 2007 21:30   

Ads




Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post28 Sep 2007 22:12   

Re: How can I calculate the period of this signal?


rakesh_vnit wrote:
hey...
the period of the signal is just the inverse of the freq of the signal. so, by takin the fft u would get the freq domain description of the signal from which u can find the freq of ur signal. now by takin the inverse of it u will come out wid the period of u signal...
why were u so amazed abt that idea?????



you say :" by takin the inverse of it u will come out wid the period of u signal..."

you can examine your idea:

>> t=linspace(-pi,pi,1000);
>> x=cos(2*pi*t);
>> X=fft(x);t1=ifft(X);max(abs(t1))

ans =

1.0000


that's right because it's period is: 2π/2π=1


but it dose not work for this :

x=cos(2*pi*10*t);
>> X=fft(x);t1=ifft(X);max(abs(t1))

ans =

1.0000

the period of cos(2*π*10*t) is :
2π/20π =0.1

and it's wrong!!!!!

on the other hand by taking ifft we only go from frequency domain of signal to the time domain not any thing.
it does'nt get the period of the signal
the above example is a breaking example.isn't it?
Back to top
rakesh_vnit



Joined: 04 Sep 2007
Posts: 75
Helped: 10
Location: india


Post28 Sep 2007 22:35   

Re: How can I calculate the period of this signal?


hey ...
u got me wrong....

wat u have to find is not fft and ifft of that again....
wat u have to do is the find fft...wat will be the o/p, the freq domain of the signal...now find the point at which this signal is havin the max value....
now here u will have that value to be some interger as u take discrete signal. so, convert it into the analog freq with samplin freq that u might have taken for the signal...
now...the freq that u have got now is the freq of the signal u want(analog).....so the inverse of this would give u the period of this...
i think i am clear now....in case of further doubt i welcome it....try this one and check it...
n chill out...this is just a discussion Very Happy
Back to top
Sal



Joined: 29 Nov 2005
Posts: 310
Helped: 37


Post29 Sep 2007 7:14   

How can I calculate the period of this signal?


Hi

first of all, I am not sure if your signal is periodic, is it?

Assuming that it is the noisy version of a periodic signal whose period is limited by the high amplitude spikes in your signal, you just need to find the difference between two adjacent spikes, from your figure, it is about 300 samples, each sample is ts = 1/369 sec.

Therefore, the sought period 300/369 is about 0.8 sec

good luck

Sal
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post29 Sep 2007 8:00   

Re: How can I calculate the period of this signal?


rakesh_vnit wrote:
hey ...
u got me wrong....

wat u have to find is not fft and ifft of that again....
wat u have to do is the find fft...wat will be the o/p, the freq domain of the signal...now find the point at which this signal is havin the max value....
now here u will have that value to be some interger as u take discrete signal. so, convert it into the analog freq with samplin freq that u might have taken for the signal...
now...the freq that u have got now is the freq of the signal u want(analog).....so the inverse of this would give u the period of this...
i think i am clear now....in case of further doubt i welcome it....try this one and check it...
n chill out...this is just a discussion Very Happy


i don't mean you in "wat will be the o/p, the freq domain of the signal... "
please dont use brief marks.

you say I should find the max value in my signal and i get the corresponding index
with this index and i have a discrete signal.then you said :
"convert it into the analog freq with samplin freq that U might have taken for the signal..."
but how?is ther any function in Matlab for this?
the continuance of the subject is clear.
I think you want reconxtruct a new version of signal and by using the max value U want to calculate the period of the signal.
is it right?

Added after 5 minutes:

Sal wrote:
Hi

first of all, I am not sure if your signal is periodic, is it?

Assuming that it is the noisy version of a periodic signal whose period is limited by the high amplitude spikes in your signal, you just need to find the difference between two adjacent spikes, from your figure, it is about 300 samples, each sample is ts = 1/369 sec.

Therefore, the sought period 300/369 is about 0.8 sec

good luck

Sal


yea
that's right I calculate the period by this method and the period ti be obtain 0.86
but i want to write a m file to calculate it.therfore i need an algorithm.
Back to top
rakesh_vnit



Joined: 04 Sep 2007
Posts: 75
Helped: 10
Location: india


Post29 Sep 2007 8:47   

Re: How can I calculate the period of this signal?


so, u want to know how to calculate the analog freq from the digatal freq.
here it is ...when u have the index,say k,(i.e, the x-axis value of the fft at which u get the max value...write an algo of how to find the max of the given value n its correspondin value on x-axis).
now, k/N is the digital freq of it, where N is the total samples of the signal u have taken. use the below formula to get the analog freq.

k/N = F/Fs....
where F=the analog freq of the signal u want to find.
Fs= samplin freq of the signal.

so, wid this u would get the analog freq. n the (1/F) would give u the period of the signal...

i think this explanation is good enough for u to write ur own algo...
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 566


Post29 Sep 2007 11:16   

How can I calculate the period of this signal?


Your ECG signal has very low amplitude at the fundamental frequency, so a plain FFT would give you poor info.

It would be better to apply some sort of non-linear filter to it first, such as computing fft(ECG_1 > 0.5) instead of fft(ECG_1).

This example shows the first strong spectral peak at about 1.23 Hz. Zoom in to see it:
Code:
clear;
load -mat ecg1.mat;
N = size(ECG_1,1);          % number of samples
fs = 369.0;                 % sample rate
t = (0 : N-1) / fs;         % sample times
subplot(2,1,1); plot(t,ECG_1); xlabel('Seconds');
h = fft(ECG_1 > 0.5);       % tricky threshold value
% Discard duplicate upper half. Scale frequency and amplitude.
freq = fs * (0 : N/2) / N;
subplot(2,1,2); plot(freq, 2 / N * abs(h(1 : N / 2 + 1))); xlabel('Hertz');

Or use a time-domain approach as Sal suggested.

Both methods are probably sensitive to changes in the waveform, so you should try many different waveforms and design some sort of adaptive algorithm.
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post29 Sep 2007 18:59   

Re: How can I calculate the period of this signal?


rakesh_vnit wrote:
so, u want to know how to calculate the analog freq from the digatal freq.
here it is ...when u have the index,say k,(i.e, the x-axis value of the fft at which u get the max value...write an algo of how to find the max of the given value n its correspondin value on x-axis).
now, k/N is the digital freq of it, where N is the total samples of the signal u have taken. use the below formula to get the analog freq.

k/N = F/Fs....
where F=the analog freq of the signal u want to find.
Fs= samplin freq of the signal.

so, wid this u would get the analog freq. n the (1/F) would give u the period of the signal...

i think this explanation is good enough for u to write ur own algo...


dear rakesh_vint

suppose this is my signal and forget the main ECG signal

How can I calculate the period of this signal?

>> t=linspace(-1,1,1000);x=cos(20*pi*t);plot(abs((fft(x))))

the sampling frequency is:1000/2=500hz
maximum FFT value index is:981
by using your formula:

981/1000=F/500
then F equal 490.5 and the period is 1/490.5=0.002
it is not true.
I want to calculte the period of this signal
what is my wrong?
the period of this signal is 2π/20π=0.1
isn't it?
Back to top
salam2000



Joined: 24 Jul 2006
Posts: 88
Helped: 12


Post29 Sep 2007 22:19   

Re: How can I calculate the period of this signal?


Quote:
the sampling frequency is:1000/2=500hz
maximum FFT value index is:981
by using your formula:

981/1000=F/500
then F equal 490.5 and the period is 1/490.5=0.002
it is not true.
I want to calculte the period of this signal
what is my wrong?


your wrong is hear:
the left peak is that you should consider, it is on 21. then 2/(21-1)=0.1.
the right peak is concluded from the discrete version of you signal. because it isn't continues this part is created symmetry and increase its frequency with increase the number of points. also you can get 2/(1000-981)=0.1. also you can use fftshift in Matlab.

Quote:
that's right I calculate the period by this method and the period ti be obtain 0.86
but i want to write a m file to calculate it.therfore i need an algorithm.


you can set a threshold and separate the peaks.


Last edited by salam2000 on 30 Sep 2007 0:02; edited 2 times in total
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 566


Post29 Sep 2007 23:20   

How can I calculate the period of this signal?


Remember that the right half of an FFT contains the signal's negative frequency components. Your ECG signal is real, not complex, so the right-half is simply a mirror image of the left-half. You can ignore the right-half.

The FFT's frequency points are spaced fs/N, where fs is the sample rate and N is the number of samples. Your N is 7200, so the FFT's left-half points 1 through 3600 represent frequencies 0*fs/N through 3599*fs/N. You can ignore the right-half points 3601 through 7200.

By the way, you may get better frequency accuracy by using Sal's method. Even better, measure the time from the first cardiac pulse to the last pulse, and divide by the number of pulses.
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post30 Sep 2007 3:28   

Re: How can I calculate the period of this signal?


salam2000 wrote:
Quote:
the sampling frequency is:1000/2=500hz
maximum FFT value index is:981
by using your formula:

981/1000=F/500
then F equal 490.5 and the period is 1/490.5=0.002
it is not true.
I want to calculte the period of this signal
what is my wrong?


your wrong is hear:
the left peak is that you should consider, it is on 21. then 2/(21-1)=0.1.
the right peak is concluded from the discrete version of you signal. because it isn't continues this part is created symmetry and increase its frequency with increase the number of points. also you can get 2/(1000-981)=0.1. also you can use fftshift in Matlab.

Quote:
that's right I calculate the period by this method and the period ti be obtain 0.86
but i want to write a m file to calculate it.therfore i need an algorithm.


you can set a threshold and separate the peaks.



let's do step by step:
you use this formula:
K/N=F/Fs
N=1000 and Fs=500 we want to find F and then the period is 1/F.
OK?
but i dont undestand for K why U use 21-1
or 1000-981

How can I calculate the period of this signal?

my left point index is not 21?
so why you subtract 1 by it. (21-1)?
you say i should use the left point indext because the right half of an FFT contains the signal's negative frequency components.

but why you subtract it?
i'm confused please help me? Shocked Crying or Very sad Crying or Very sad
and you mentioned i can set a threshold to seprate it
the value of the threshold is important if it change the maximum value indext will be change.Rigth?i think using threshold is not need the maximum indext value is
clear
for example for this signal from the above Pic it's value is 3 and the other indext value is 999.
thus using threshold is not nedd.Right?

Added after 17 minutes:

the last plot is for cos(2πt) not for cos(20πt) but it dose'nt important I dont know for cos(20πt) FFT plot why you (21-1)?
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post30 Sep 2007 12:01   

Re: How can I calculate the period of this signal?


Finally i see the subject
i use this command:
t=linspace(-1,1,1000);x=cos(2*pi*t);

by using linspace(-1,1,1000) i divide the x-axis to 1000 point and the intreval of each two point is 0.002 then if i want to find each indext's time I should do:
t_1=-1
t_2=-1+0.002
t_3=-1+2*(0.002)
t_4=-1+3*(0.002)
.
.
.
t_n=-1+(n-1)*(0.002)


similar this if i want find any indext correspondinf frequency :
i will get thjis relation:

f_n=((n-1)/N)*Fs

thats right
thanks every body to guidence me.

but there is an other question we know that the signal energy is concentrate at a frequency by using the energy of the signal how can i find the period?

>> t=linspace(-1,1,1000);x=cos(20*pi*t);
subplot(211);plot(abs((fft(x))));subplot(212);plot(abs(fft(x.^2)))

by Energy plot how can i find the period?

How can I calculate the period of this signal?
Back to top
rakesh_vnit



Joined: 04 Sep 2007
Posts: 75
Helped: 10
Location: india


Post30 Sep 2007 13:00   

Re: How can I calculate the period of this signal?


hey..
i think already ppl have ans. the question that u put to me. so, i am not takin the pain i=of ans it again...the neg. freq part comin on the right hand side on the plot for the fft unction in matlab.

n as i see u have lot of questions....
abt the question why use (k-1) i.e, 21-1 in ur case, thts 'coz matlab stores it values in an array from 1 to N n not from 0 to N-1...which is actually the way it shold be accordin to the formula....refer opphenham n schafer, it will give u a good ref to the formula n its derivation.....

i think that this will ans ur question....
n abt the threshold i didnt understand the statement that u made....even i am waitin for a reply by somebody....!!!
Back to top
salam2000



Joined: 24 Jul 2006
Posts: 88
Helped: 12


Post30 Sep 2007 13:53   

Re: How can I calculate the period of this signal?


Drar active sudent,
why you are in hurry....
-1 is beacase you plot your curve from 1:1000 instead plot from 0:999
I think it's better you have a glance to Oppenheim book before ask question and become hopeless Very Happy
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post01 Oct 2007 8:56   

Re: How can I calculate the period of this signal?


salam2000 wrote:
Drar active sudent,
why you are in hurry....
-1 is beacase you plot your curve from 1:1000 instead plot from 0:999
I think it's better you have a glance to Oppenheim book before ask question and become hopeless Very Happy



I 'm in hurry because i have less time to finished my project
I know i can read oppenheim and get my reply buti haven't any time
thus i create this topic
I get my reply but
a question is still contiue if anyone help me this will finished
please see this plot

How can I calculate the period of this signal?

x(t)=cos(20πt)
the firat plot is FFT of cos(20πt) and the other one is the Energy of it(FFT(x˛))
by using FFT plot i get the period :
2/(21-1)=0.1 and it's right
in FFT the axis(x-axis)is from 0-1000
0 ≈ 0 HZ
1000 ≈ fs
21 ≈ 10Hz
by this realation I find period equal 0.1 Very Happy Very Happy

but in FFT energy( the second plot) how can I find the period? Rolling Eyes
more accurate:
in FFT energy plot; what dose the axis correspond?

0 ≈ 0Hz
1000 ≈ ?fs

i think 1000 ≈2fs becuse when x(t) multiply by x(t) the bandwidth of signal is twice
but this realation is wrong.

if 1000 ≈ fs/2 then indext 41 will be (41-1) ≈10Hz and this will be true

is it right?why?i think 1000 should be equivalent 2fs not fs/2. (in FFT plot energy)

do you understand me?
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 566


Post01 Oct 2007 14:38   

How can I calculate the period of this signal?


If you square a sinewave, you get a DC-offset sinewave at twice the frequency.

Power and energy calculations should be done after calculating the FFT, not before.


Last edited by echo47 on 01 Oct 2007 14:50; edited 1 time in total
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post01 Oct 2007 14:50   

Re: How can I calculate the period of this signal?


yea that's right
I consider it in this manner:
Signal Energy≡FFT(signal˛)
i konw squaring a signal will be double the bandwith of the signal
My question is by using the Signal Energy plot can we find it's period or not?
the signal energy plot show that the main content of signal be concentrated at indext 41 of energy plot.
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 566


Post01 Oct 2007 14:59   

How can I calculate the period of this signal?


I think you and I hit the "submit" buttons simultaneously. Wink

You should apply your energy squaring calculation to the FFT's output points, not to the input waveform (that just creates distortion and harmonics).

Don't forget that the FFT outputs complex numbers.
Back to top
salam2000



Joined: 24 Jul 2006
Posts: 88
Helped: 12


Post01 Oct 2007 21:39   

Re: How can I calculate the period of this signal?


I don't understand you;
but these relation may help you:
cos^2 (x)=(1+cos(2x))/2
sin^2 (x)=(1-cos(2x))/2
therefore the power two equivalent to twice frequency.
Back to top
m_eh_62



Joined: 05 Mar 2007
Posts: 51
Helped: 5


Post02 Oct 2007 2:41   

Re: How can I calculate the period of this signal?


echo47 wrote:
I think you and I hit the "submit" buttons simultaneously. Wink

You should apply your energy squaring calculation to the FFT's output points, not to the input waveform (that just creates distortion and harmonics).

Don't forget that the FFT outputs complex numbers.



Very Happy
thanks for your help
yea that's right
I should assume (FFT(x))˛ not FFT(x˛)


How can I calculate the period of this signal?
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing -> How can I calculate the period of this signal?
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
Delay circuit that can delay the input signal 1 clock period (9)
16f877a - PWM period doubt how can i get the 20ms (4)
how to calculate the frequency of a signal ... (3)
How does the Hspice calculate the DFT of a signal ? (4)
How to calculate the track length of a signal? (4)
How we can calculate position of the Patch on the Substrate? (8)
how to calculate the gain of this circuit? (27)
How to calculate the duty cycle of this circuit (5)
How to calculate the Y-parameter for this network? (1)
how to calculate the (W/L) of this current memory cell (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS