# Is it possible to separate two signals in Mathematica?

I have asignal and I would like to decompose it into two..

this is the datasetTot of both signals

ListPlot[datasetTot, PlotStyle -> {Black, Black}]


I know that this signal is a sum of two signals whose shape is like this

My question is: can I get the green and red signals separately from the original data datasetTot?

update

the green and red signals are

green={-2 Tanh[1 - x] + Tanh[x], Tanh[x] + 2 Tanh[1 + x]}
red={3/2 (Tanh[2 x] - Tanh[2 (1 + x)]), 3/2 (Tanh[2 - 2 x] + Tanh[2 x])}

• Can you assume that you know the green and red signals ahead of time? (Data/definitions for them are not provided in your example). If so, it seems like you could NMinimize a least-squares expression for the black signal as a linear combination of the red and green signals (with two real parameters describing the coefficients of the red and green contributions) May 26 at 10:35
• Do you know equations that red and green curves are described with? May 26 at 10:45
• I only know how the profiles of the two signals would be, as I showed in green and red which is synthesized data. May 26 at 11:42
• Please provide the equations for the two profiles. Afterwards, you could use NonlinearModelFit to get the two coefficients (as Joshua already proposed). May 26 at 12:37
• kindly, see update for the green and red profiles. May 26 at 13:15

Not very elegent approach ... You fit the linear combination of both components to obtain the coefficients (which in your case seem to be 1). Then, you separate the signal by subtracting one of the components (I used the green one).

data = (* ... *);

green = {-2 Tanh[1 - x] + Tanh[x], Tanh[x] + 2 Tanh[1 + x]};
red = {3/2 (Tanh[2 x] - Tanh[2 (1 + x)]), 3/2 (Tanh[2 - 2 x] + Tanh[2 x])};

NonlinearModelFit[#1, g #2 + r #3, {g, r}, x] &, {data, green,
red}];

Show[ListPlot[data], Plot[{fit[[1]][x], fit[[2]][x]}, {x, -4, 4}]]

Through[fit["BestFitParameters"]]

(* {{g -> 1., r -> 1.}, {g -> 1., r -> 1.}} *)


separated =
Table[{#[[1]], #[[2]] - g green[[i]], g green[[i]]} /.
fit[[i]]["BestFitParameters"] /. x -> #[[1]] & /@
data[[i]], {i, 2}];

Show[{
ListPlot[separated[[All, All, {1, 3}]], PlotRange -> All, PlotStyle -> Green],
ListPlot[separated[[All, All, {1, 2}]], PlotRange -> All, PlotStyle -> Red]
}]