43 views (last 30 days)

I am working on a filter for a heartbeat sensor. Therefore I want to fit a 'perfect' heart beat graph (without noise) onto a signal with noise. Is there a function in matlab to scale the 'perfect' data such that it fits onto the signal with noise?

Since a heart rate is not constant, the perfect graph needs to be scaled in both amplitude and time/frequency in order to fit it onto the signal with noise.

Salaheddin Hosseinzadeh
on 3 Jun 2015

Hi,

I recently found about Savitzky-Golay filter, which I think you will like it very much for your application.

Have a look at MATLAB help for

doc sgolay

Hope this helps.

Salaheddin Hosseinzadeh
on 3 Jun 2015

Cool! It's getting interesting now! And the more I amaze there are more chances that I actually won't be able to help.

Thanks so much for the graphs! I like them.

So let me review what I learned.

D determines the phase shift of the sin waves, and A is the frequency. I believe you can ignore D, unless you really wanna fit the data, which I think you just want to measure the heart bits.

A can be found either by taking an fft of the signal and observe its frequency spectrum which gives you the A or, even easier, you can get two consecutive peaks and measure the time in between peaks which give you T (period of the sin wave).

For this specific case, two sin waves are orthogonal so when one is max the other one is zero! One has a frequency twice the other one. So if you find max and min of the signal, their difference divided by two will corresponds to B. And I guess C is the max + min of the signal.

If you need D for sure, you have to define a source in time, lets say phaseshift is relative to the peak you can get the total number of samples before the first max or mean, this time can be converted to phase shift.

BTW, this is not a MATLAB question really!!

Give it a try.

Salaheddin Hosseinzadeh
on 4 Jun 2015

Dear Roelst,

I'm glad that it helped.

If you have curve fitting toolbox, you may wanna have a loot at the fitting options, type cftool in command window and you will see the GUI

cftool

As far as I remember there are built in sin wave fittings, using multiple sins, you can even define your own custom function if you like.

Have a look at that, it may help you with the fitting.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.