I guess x[2] is the center for ball 2, and x[5] is the coordinate for the wall.

If there distance x[5]-x[2]<size2 (assume x[5] is always large than x[2] )

Then the ball collide with the wall, so some code are used to calculated the collision process.

If you just want to change the wall position, you should change value for x[5] and keep the rest the same.

If you just change where you draw the wall, and you did not change the code to check the collosion: x[5].

The ball will be bounced back at the same place.

It is the same as you draw the wall at the wrong place.