Calculating frequency of a sine wave with varying frequency

3 visualizaciones (últimos 30 días)
Amer
Amer el 8 de Mayo de 2014
Respondida: Amer el 8 de Mayo de 2014
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,

Respuesta aceptada

Amer
Amer el 8 de Mayo de 2014
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.

Más respuestas (1)

Carlos
Carlos el 8 de Mayo de 2014

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by