This does not seem like good code to me. It is likely that what it does is not what its author intended.
For example, if one of the 'locs_Rwave' elements happens to be less than the first element of 'locs_Qwave' (which is not true in this particular case,) then when j indexes that element of 'locs_Rwave' and when the inner loop sets i = 1, there would be an attempted access to locs_Qwave(0) which would result in an error message. One can only speculate as to what was intended here.
Also the line
is strange because size(locs_Rwave) is a two-element vector. Fortunately for the author the colon operator apparently ignores the second part of it, but why didn't the author write a more straightforward size(locs_Rwave,1) or numel(locs_Rwave)?
Furthermore, I would guess that q was meant to be empty at the beginning instead of being set to the scalar quantity zero. If so, the proper code should have been "q = ;". That zero will persist as locs_Qwave elements are appended to q.