# given a mixture of two signals, how to separate it to its base components?

I have a signal that contains two components. How can I separate it two its two components in matlab? Please note that the location and shape of components are different in each experiment and we do a lot of experiments. It should automatically detect the two components based on the frequency contents. I have added this comment because some people suggested c1 = x(1:80);c2 = x(81:end);

I do not mean such separation.

• c1 = x(1:80);c2 = x(81:end); – John Mar 8 '14 at 0:21
• hey john! are you kidding me?! that's of course what I do not mean. the location and shape of components are different in each experiment and we do a lot of experiments. It should automatically detect the two components based on the frequency contents. Why did you vote negative while you did not even understand the question? – user8171 Mar 8 '14 at 14:51
• I didn't vote negative. – John Mar 8 '14 at 17:12
• And what is a 'component' in your eyes? What makes one decomposition better than any other? – Jazzmaniac Mar 8 '14 at 18:29
• John: Thank you for your reply; I apologize to you. Jazzmanica: Hi there, the frequency of the components are different. As it can be seen in this picture, two components are visibly distinguishable. Right? They have different frequencies. Here I have shown a clear example, however, sometimes they overlap and you can only see the summation. Anyway, either overlapped, shifted, dislocated etc the differentiation should be based on frequency of each component. I hope this time it is clear. – user8171 Mar 8 '14 at 22:48

I would suggest you take a look at 'independent component analysis', and 'blind source separation' tasks. In general, given a signal of mixtures of components to be separated to its contents well addressed by optimization in complicated cases. Here you show one example, but probably in each experiment you have something very different. I will also take a look at my files to see if still I have relevant codes to solve it or not.

• And how do you know what a component is if you have just a single realization of a mixture? If you are assuming certain properties of components that allow a single observation decomposition you should state them clearly. – Jazzmaniac Mar 8 '14 at 18:31
• Hi there, the frequency of the components are different. As it can be seen in this picture, two components are visibly distinguishable. Right? They have different frequencies. Here I have shown a clear example, however, sometimes they overlap and you can only see the summation. Anyway, either overlapped, shifted, dislocated etc the differentiation should be based on frequency of each component. I hope this time it is clear. – user8171 Mar 8 '14 at 22:47
• Alberto, welcome to the site. I edited your answer a little bit by keeping only the answer part. For the comments other than an answer, you can add them as a comment on the OP once you get enough reputations. I also suggest you add more details to your current answer. Thanks – lennon310 Mar 9 '14 at 2:15
• @AlbertoCastilloGraza, please read terms and conditions of the site before using it. Everything posted here exists under Creative Commons license. This means that everything you post is public information, and anyone can edit anything on this site provided sufficient reputation. As per offensive comments, we have zero tolerance toward those, so please refrain from aggressive language. – Phonon Mar 11 '14 at 22:11

In your example, the most important difference appears to be in frequency. If this is to be expected, filtering would be the natural approach.

• Thank you for your reply. I used matlab's fdesign tool and made some filters such as lowpass and banspass. I also used Daubechies biorthogonal lowpass 9/7 filters. In all cases, only the overall shape was smoothed. Pushing the filters removes both components or just smooths them. For sure I am not a good filter design guy. If you have any idea to write some lines of codes, I would really appreciate that. – user8171 Mar 8 '14 at 22:56
• The example implies that the frequency of one of the parts of the signal is about double than that of the other, or even further away. I would not start with wavelet transform in this situation. Maybe I'd try a simple butterworth lowpass filter with a degree of 4 and the cutoff frequency right above the lower signal. Not much filter design to do there. – user7358 Mar 9 '14 at 8:35

If you want to separate based on frequency, then it seems like you want to work in the frequency domain. You can either calculate a spectrogram to see frequencies' powers over time, or you can calculate the PSD across an entire experiment and decompose the signal that way. You can then get the separated signals by creating two copies (one for each component you want to recognize) of the Fourier-domain signal, zeroing unwanted Fourier coefficients (zeroing different sets of coefficients in each of the two copies), and reconstructing the two signals. To reconstruct signals from a spectrogram, make sure the window overlap is at least 50%.

If you want to automate it a little more, you might perform PCA on the spectrograms. Matlab has native FFT, PCA, and spectrogram functions, so it's all very quick.

Maybe you should use Wavelets or the Matching pursuit algorithm. I see two perfect Gabor atoms there. The new MATLAB has implemented Matching Pursuit.