Perhaps the wav file is in stereo. Then abs(max(y)) is a vector and dividing y by this vector leads to this problem. Or perhaps yy and w do not have equal sizes, such that yy.*w must fail.
It would be useful if you post the complete error message, such that we do not have to guess, where the error occurs.