Generate a sinusoid function to data

4 views (last 30 days)
Tim Ubbink
Tim Ubbink on 3 May 2017
Answered: Greg Heath on 8 May 2017
Hi there,
On beforehand, I want to say that I am a complete rookie when it comes to using Matlab.
So I'm trying to create a classification based of a set of data. The data is created by an instrument which measures N (m/s2) over time. I want the classification to be represented by an equation or function. In figure 1 I plotted the data over n.
The eventual goal is to fit the generated equation to multiple datasets.
Does anyone know if it's possible to generate a function or equation to this graph? Is it best to generate an sinusoid function? And how can I do this using Matlab?
Cheers,
Tim

Answers (2)

Star Strider
Star Strider on 3 May 2017
I do not know what you mean by ‘classification’. If your signal is composed of several different signals and you want a relatively straightforward way of determining what they are, the procedure most likely to give you the result you want is independent component analysis. Search the File Exchange for an appropriate approach for your data.
If you simply want to do curve-fitting of your data, it is best to begin by calculating the fft (link) of your data to determine the significant frequency components. There appear to be several in your data.
I would then use bandpass filters for each significant frequency (Chebyshev Type II design would likely be best), then fit the output of each filter using for example the procedure in Curve fitting to a sinusoidal function (link), or How to filter noise from time-frequency data and find natural frequency of a cantilever? (link). The final fitted function would be the sum of these. You can at best get an approximation.
  2 Comments
Tim Ubbink
Tim Ubbink on 8 May 2017
Edited: Tim Ubbink on 8 May 2017
Hi Star Strider,
Many thanks for your answer!
Reading your comment it feels like you interpreted my data as chemical analysis. But I could be wrong.
The thing is: I am trying to identify the re-occurrence of these peaks in a larger set of data. This way I was hoping to identify undertaken activities by a user. As (poorly) illustrated in the second figure.
The earlier figure, figure 1, represents walking. So my goal is to identify these three activities from each other using a function or equation of some sort.
I hope this clears things up.
Greets,
Tim
Star Strider
Star Strider on 8 May 2017
My pleasure.
With your clarification, independent component analysis is likely the most appropriate procedure. You would have to use it separately on each activity segment. Then a Fourier transform fft (link) if necessary would further identify the frequency components.
For references, I would begin with Independent Compononent Analysis: A Tutorial Introduction (ISBN: 9780262693158), and the File Exchange contribution PCA and ICA Package (link).
Also, the short-time Fourier transform (STFT, the spectrogram function) is used in electroencephalogram pattern classification (I published on this a couple decades ago), and the same approach could be appropriate for what you are doing. We used a linear discriminant analysis with PCA, but there are likely better and more efficient classification methods available now, including neural nets.

Sign in to comment.


Greg Heath
Greg Heath on 8 May 2017
If you only have the three classes shown, it looks like they can be classified using their spectral representations via, for example, the amplitudes obtained from a fft.
It looks like a simple classifier like LINEAR, QUADRATIC or NEAREST-NEIGHBOR using spectral amplitudes will do the trick.
It doesn't seem like a neural net is necessary.
Hope this helps.
Thank you for formally accepting my answer
Greg
PS How many points in each sample?

Community Treasure Hunt

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

Start Hunting!