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 Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by