Extract frequency from list of timed values

francesco  spaggiari's icon

Hello people:)
Little hopefully easy question here...I have a list of timed values that oscillate around zero, for example (3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3), and I want to calculate its frequency.
How can I do it?

Max Gardener's icon

I'm sorry, but unless I am seriously misunderstanding you, it's not an easy question at all.

The distribution of zeros (positive or negative going) is aperiodic in the sample you're giving (draw it on a napkin). Is your point that this whole sequence periodically repeats? Do you simply want to count zero crossings and assume that's the frequency? That's not the case at all for all kinds of periodic waveforms. I don't think you've given us as clear a description of what you think you're going to be monitoring and the uses you wish to put it to for a very useful answer.

volker böhm's icon

you could try auto-correlation. the distance between the local maxima is the period of the repetition.

Max Gardener's icon

Hey, Volker. That would strike me as a possible solution, but I really wasn't sure what he had in mind....

francesco  spaggiari's icon

Hello guys ;)
I have the recording of an Electroencephalography, measured in µV (microvolts) every 4ms, and here are the actual first measurements: "-0,74" "-4,49" "-0,03" "0,88" "1,39" "4,07" "-0,93" "-2,39" "-1,83" "-5,72" "-0,03" eccetera.
So yes, I think I just need to calculate the 0 crossing and assume that that's the frequency, but I'm a bit lost on how to to this:) I have all my measurements (2555 measurements) in a qlist object. Thanks so much:)

ben sonic's icon

Did you mean something like this?

Max Patch
Copy patch and select New From Clipboard in Max.

volker böhm's icon

as Max pointed out, zero-crossing-counting might not work for all cases.
but it's easy enough to just try it out, have a look at [> 0.] and [change] etc.

Roman Thilenius's icon

he is not talking about signals at all, just floats.

i also would start from zero crossing, but there is anpother simple approach which starts by a list of _delta values (the difference between this value and the last one)

you will end up with a list which tells you about the _direction of movement (this value was bigger or smaller than the last one?)

if there are irregularities in the incoming data you can smooth them out later, but there is no general method for that as it really depends on the data.

francesco  spaggiari's icon

Thank you so much guys for the tips, will try them out and let them know how it goes:) I think >0 and change works for me...