Instructions
Open your menu. Put your starter Pokemon in the first position by using the "Switch" button.
Enter a battle and weaken your opponent until his health bar is red. Use Paralyze, Sleep or other debuffing attacks to weaken it.
Open your items menu and select an Ultra Ball to throw at Pokemon.
Press the "B" and "Up" buttons at the same time when an Ultra Ball leaves your hand. Let go of the buttons. Quickly press them again and hold them down until the Pokemon is caught.
Practice this with various Pokemon until you have mastered the timing.