You must be referring to this answer which contains a link to the function on the file exchange.
Make sure the file is on your Matlab path. Also make sure you're using version 4.0.0 or later to copy yyaxis plots.
After viewing your code, I see where you're using the function incorrectly. You're copying the left and right axes separately. copyUIAxes copies both the left and right axes. So you're actually producing two copies on the same figure.
Here's the correction
plot(ax, 1:5, rand(1,5), '-')
plot(ax, 1:.2:5, rand(1,21), 'o')
axLeft = copyUIAxes(ax, newFig);