Assume that we have two matrices over the complex field i.e. $A\in\mathbb{C}^{m\times n_1}$ and $B\in\mathbb{C}^{m\times n_2}$.
Let their range spaces be the sets $$R(A)=\{A\mathbf{x}|\mathbf{x}\in\mathbb{C}^{n_1}\}$$ and $$R(B)=\{B\mathbf{x}|\mathbf{x}\in\mathbb{C}^{n_2}\}$$ respectively.
I want to know if there is a systematic way to tell whether the range spaces have common elements. I am trying to check this in Matlab thus I am trying to find an algorithm.
In other words if the columns are s.t. $A=\begin{bmatrix}\mathbf{a}_1&\dots&\mathbf{a}_{n_1}\end{bmatrix}$ and $B=\begin{bmatrix}\mathbf{b}_1&\dots&\mathbf{b}_{n_2}\end{bmatrix}$ how to tell if the following is true $$\sum_{i=1}^{n_1}x_i\mathbf{a}_i=\sum_{i=1}^{n_2}y_i\mathbf{b}_i\Leftrightarrow x_i=y_i=0 \text{ for all }i$$
The matrices are fixed, so I am not looking for a way to construct them.