# mixing two signal for blind source separation

is this the right way to mix two signals? (I am self learning Blind source separation)

% house keeping
close all,clc;

fe = 1000;
f1 = 10;
f2 = 35;
t = 0:(1/fe):1-1/fe;
s1 = sin(2*pi*f1*t);
s2 = cos(2*pi*f2*t + 180);

figure (),
plot(t,s1), hold on
plot(t,s2)
legend ("s1","s2")

A = rand(2,2);

s = [s1; s2];
obs = A*s;

figure (),
plot(t,obs(1,:)), hold on
plot(t,obs(2,:))
legend ("obs1","obs2")

• There a dozens of ways to do this. It really depends on the requirements and constraints of the specific application or problem you are working on. Commented Jun 6, 2023 at 18:31
• Could you review my answer?
– Royi
Commented Jul 5, 2023 at 17:06

The simplest model for source mixing of $$m$$ sources into $$n$$ measures would be:

$$\boldsymbol{y}_{j} = {a}_{j, 1} \boldsymbol{x}_{1} + {a}_{j, 2} \boldsymbol{x}_{1} + \ldots + {a}_{j, m} \boldsymbol{x}_{m}, \; j = 1, 2, \ldots n$$

Where both $$\boldsymbol{y}_{j}$$ and $$\boldsymbol{x}_{i}$$ above are vectors of samples.

We can write this in a matrix form:

$$\boldsymbol{y}_{j} = \boldsymbol{X} \boldsymbol{a}_{j}, \; j = 1, 2, \ldots n$$

Or more generally by:

$$\boldsymbol{Y} = \boldsymbol{X} \boldsymbol{A}$$

Where:

$$\boldsymbol{Y} = \begin{bmatrix} \mid & \mid & & \mid \\ \boldsymbol{y}_{1} & \boldsymbol{y}_{2} & \dots & \boldsymbol{y}_{n} \\ \mid & \mid & & \mid \end{bmatrix}, \; \boldsymbol{X} = \begin{bmatrix} \mid & \mid & & \mid \\ \boldsymbol{x}_{1} & \boldsymbol{x}_{2} & \dots & \boldsymbol{x}_{m} \\ \mid & \mid & & \mid \end{bmatrix}, \; \boldsymbol{A} = \begin{bmatrix} \mid & \mid & & \mid \\ \boldsymbol{a}_{1} & \boldsymbol{a}_{2} & \dots & \boldsymbol{a}_{n} \\ \mid & \mid & & \mid \end{bmatrix}$$

So in MATLAB code you can do something like:

numSamples = 100;
numSources = 10; %<! n
numSignals = 5; %<! m

mX = randn(numSamples, numSources);
mA = randn(numSources, numSignals);

mY = mX * mA;


You may even make each column of $$A$$ to have a sum of 1.

You may also chose the convention of signals being rows in the signal matrix. It will be equivalent to apply the transpose operator on the matrices above.