Calculating frequency of a sine wave with varying frequency

조회 수: 3 (최근 30일)
Amer
Amer 2014년 5월 8일
답변: Amer 2014년 5월 8일
I have a sine wave with a varying frequency. I would like to plot the frequency over time.
My approach was to find all values >0 and set them to 1, and all other values to 0.
Now I have a vector, for example:
A = [1 1 1 1 0 0 1 1 1 0 0 0 0 1 0 0]
If I could sum all groups of ones and put the result in another vector I could calculate the frequency because I know how many sample points I have per time unit.
In short, what I would like to do is to sum all groups of ones separately and put them in a vector in the correct order, as the groups appear.
So the result for vector A above would be:
B = [4 3 1]
i.e. the sum of the first group of ones is 4, there are four ones. The second group has 3, and the last group has 1.
Thank you for you time.
kind regards,

채택된 답변

Amer
Amer 2014년 5월 8일
Thank you,
I have a sine wave similar to this one,
How can I then plot the changing frequency? I would like to plot it over time.

추가 답변 (1개)

Carlos
Carlos 2014년 5월 8일

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by