Draw the free-body diagram of wedge and block.

A wedge with mass M rests on a frictionless horizontal table top. A block with mass m is placed on the wedge. The masses M and m are moving with same acceleration a and the direction of all forces on masses are shown below figure.
Let F be the magnitude of horizontal force acting on the wedge along horizontal direction.
From the above figure, the net horizontal force acting on the block is given by,
….. (1)
Here, is normal force exerted by wedge on the block, and be the angle of inclination.
From the Newton's second law of motion, the horizontal force acting on the block is given by,
Substitute ma for into equation (1).
….. (2)
The net vertical force acting on the block due to vertical upward force and vertical downward weight is given by,
….. (3)
For no motion along vertical the net vertical force acting on the block should be zero.
Substitute 0 for in equation (3).
….. (4)
Divide equation (2) with equation (4).
From Newton’s second law of motion, the net external force acting on the total mass of block and wedge is given by,
Substitute for a in the above equation.
Therefore, the required magnitude of the force is.