Is there any way to fix frequency using the fit() function and “sin”?

5 views (last 30 days)
I am using the fit() function with a 'sin' model. Is there a way to fix the frequency? As I am analyzing the data for circadian rhythm of cardiac functions, the frequency should be 1 for 24 hours data, 2 for 48 hours data and 3 for 72 hours data.
After I get the “fit”, I will calculate the amplitude (peak value from the mean value) and acrophase (the timing of the peak values) of those data.
Is there any way to do so?

Answers (2)

Walter Roberson
Walter Roberson on 27 Nov 2021
No. You should create a custom model for that.
Are you sure that you want the frequency to be 2 for 48 hours data? As in sin(2*pi*F*t) and you would want F to be 2 for 48 hours data? Frequency is cycles per unit time, and the unit time is the same for 24 hours as for 48 hours, so however many cycles you are expecting for 24 hours, frequency 2 for 48 hours would imply that you would want 4 times as many cycles. For example if the unit time is "days" then frequency 1 for 24 hours would be one full cycle, but frequency 2 for 48 hours would be 2 full cycles for the first 24 hours, and an addtional 2 full cycles for the second 24 hours, for a total of 4 full cycles.
It is not clear to me that a fixed frequency is justifiable in circadian rhythm studies. Isn't part of the hypothesis that the person might have a different rhythm ?
If you really did have a fixed frequency, just with unknown amplitude and phase, then it seems to me there would be other ways of recovering those values. But I am not presently convinced that fixed frequency can be justified.

Ken Takahashi
Ken Takahashi on 27 Nov 2021
Thank you very much for your quick answer. It is very helpful.
I attached the graph for typical circadian rhythm and not typical from 24 hours Holter electrocardiogram. As you can see in the graph, I want to measure some parameters, which represent the heart function. Usually there are one positive peak and one negative peak, which means 1 cycle during 24 hours. This is not my original idea. There were already several scientific papers using this methods, to fit the data for sin curve.
I measure those functions in person during usual life. Therefore, they usually show those kinds of circadian cycle in 24 hours.
Regards,
Ken Takahashi
  2 Comments
Walter Roberson
Walter Roberson on 27 Nov 2021
I suggest you take the signal, subtract the mean of the signal, fft(), take the first half of the array, find the peak absolute value. Convert the index of the maximum value into a frequency according to the time separation -- index 1 should never be the peak; index 2 would be the peak if the frequency is 1 cycle over the elapsed time of the test; index 3 would be the peak if the frequency is 2 cycles over the elapsed time of the test, and so on. See the first example in the fft() documentation to see how to calculate the frequency vector.
Ken Takahashi
Ken Takahashi on 27 Nov 2021
Thank you very much for your detailed comments again.
I am trying calculations along with your suggestions.
Regards,
Ken Takahashi

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!