Calculating frequency of a sine wave with varying frequency

3 次查看(过去 30 天)
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