Find B given A and impulse response of B/A
The vector impr holds the impulse response of length nh of an all-pole filter with denominator coefficients given by a. Let's call this impulse response $g(n)$. The impulse response $h(n)$ must satisfy the equation

$$h(n)=(g*b)(n)\tag{1}$$

where * denotes convolution. With the given data, this results in an overdetermined system of linear equations, the system matrix of which is the Toeplitz matrix egqs. The last line in the code solves this overdetermined system of linear equations corresponding to (1) in a least-squares sense. You could achieve the same using the backslash operator:

b = egqs\h';