Ask Your Question

How do I write a frequency function? [closed]

asked 2014-03-06 16:05:20 +0200

burnst14 gravatar image

updated 2015-09-11 20:33:51 +0200

Alex Kemp gravatar image

Version:, English, Calc Ubuntu 13.10, English Hello, I am working on some science fair stuff and I have respiration data that was taken by a relative pressure sensor that was connected to a bladder that was strapped around the test subjects’ stomachs. As they inhaled, they created pressure against the bladder raising the pressure readout and vice versa, which created a somewhat harmonic wave (I’ve attached a graphic). I need to write a function that will calculate the average frequency of troughs or breaths. Something that could perhaps take the frequency of two or so troughs in front and behind the one in question and average them to give a breath frequency. Does anyone know how to write such a thing?

Someone on another forum said this: "I would approach this by creating a new pair of data columns that indicate each peak and trough point using basic less-than / greater-than comparisons of a prior value (or perhaps 3 prior readings for noise smoothing purposes). It should then be possible to determine each period and display these in another column. These periods can then be averaged as required in the moving 5-period manner indicated (again in a new column) and graphed as required."

I didn't understand that. I've attached a file of some sample data. C:\fakepath\Data Sample.ods Feel free to edit, alter and otherwise play with it if it helps. It will certainly help me if you can return a file that has an example of what you're saying.


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-02-20 06:17:25.586046

1 Answer

Sort by » oldest newest most voted

answered 2014-03-06 19:39:13 +0200

Regina gravatar image

updated 2014-03-06 21:09:23 +0200

I guess, it would be doable with FFT (Fast Fourier Transform). But unfortunately LibreOffice has no build in solution for it.

Here another, somehow primitive solution:

You can observe the time points, when the curve increases. Then you build the difference of this time points to get the time from one up to the next up and last you make a average over this durations. In detail:

To get a time point for curve increases, you calculate moving average. You need to experiment with the span, for example 200 values, e.g. in D3 =AVERAGE(B3:B202), copy down. Next calculate the difference between average and value, e.g. in E3 =B3-D3, copy down. Now look, whether there is a switch from - to + ,e.g. in F3 =AND(E3<0;E4>0).

Now filter the data with criteria column F = true. Put the filter result into a different sheet, e.g. Sheet2.A3.

On this Sheet2 you do the next calculations. Build the difference of adjacent time points, e.g. in G4 =A4-A3. Copy down, but not too far. The last moving averages are not valid, because they span ranges with no data. This differences in column G tell you, how long it needs from one breath to the next.

Calculate the average of this differences.

Ask 2014-03-06 Frequency 13941180328547709 suggestion.ods

If you will show the whole data in the chart, you need to be patient, because it lasts some time to generate the points in the chart. LibreOffice does not hang, but it is very slow.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-03-06 16:05:20 +0200

Seen: 2,608 times

Last updated: Mar 06 '14