Let $\tilde{\Delta}$ is a $q \times q$ matrix with variable elements, and $\Delta$ is a $k \times k$ diagonal matrix whose elements are non-zero elements of $\tilde{\Delta}$. Find constant matrices $M$ and $N$ such that $\tilde{\Delta} = M \Delta N$.
We can try to choose $M$ or $N$ in the form of identity matrix (or close to it if $q \neq k$) and find $N$ as
$$N = \Delta^{-1} M^{\\+} \tilde{\Delta} \qquad \tag{1}\label{1}$$
or $M$ as
$$M = \tilde{\Delta} N^{\\+} \Delta^{-1}. \qquad \tag{2}\label{2}$$
For example, let $\tilde{\Delta} = \begin{pmatrix}
\Delta_1 & 0 & 0\\
\Delta_2 & \Delta_3 & 0\\
0 & 0 & \Delta_4
\end{pmatrix}$, then $\Delta = diag(\Delta_1,\Delta_2,\Delta_3,\Delta_4)$. By trial and error, I found matrices $M$ and $N$ that satisfy the problem: $$M = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}, N = \begin{pmatrix} 1 & 0 & 0 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}.$$
But substituting one of these matrices to $\eqref{1}$ or $\eqref{2}$ results in matrices with non-constant elements, for example, substituding M to $(1)$ results in $N = \begin{pmatrix} 1 & 0 & 0 \\ \frac{1}{2} & \frac{\Delta_3}{2 \Delta_2} & 0 \\ \frac{\Delta_2}{2 \Delta_3} & 1/2 & 0 \\ 0 & 0 & 1 \end{pmatrix}$.
Question: Is there any way to solve this problem other than trial and error?