Based on the properties of the core-EP inverse and its dual, we investigate three variants of a novel quaternion-matrix (Q-matrix) approximation problem in the Frobenius norm: $$\min \Vert \mathbf {A}\mathbf {X}\mathbf {B}-\mathbf {C}\Vert _F$$ subject to the constraints imposed to the right column space of $${\mathbf{A}}$$ and the left row space of $${\mathbf{B}}$$ . Unique solution to the considered Q-matrix problem is expressed in terms of the core inverse of $${\mathbf{A}}$$ and/or the dual core-EP inverse of $${\mathbf{B}}$$ . Thus, we propose and solve problems which generalize a well-known constrained approximation problem for complex matrices with index one to quaternion matrices with arbitrary index. Determinantal representations for solutions of proposed constrained quaternion matrix approximation problems obtained. An example is given to justify obtained theoretical results.