update function for plotting the compound action potential to work with any index