OK, this isn't complete, but is probably the simplest way to build something to do what you'd like -- it would need to be refined and made into a function, but the general idea is pretty simple...using the same [x y] data had before in sorted order...
if X(i)~=X(i-1), j=j+0.5; end
title('Simulated Grouped by Wave Number')
Now, one has a separate bar() object handle for each bar so can set color as desired...this just cycles through the (somewhat ugly) default sequence; you can define whatever color array you wish.
The biggest refinement I see missing here is not computing the midpoint of the groups for locating the tick marks so only have one label for the wave number group--I ran out of time altho don't think it's hard, one just needs a running sum of the XendPoints values for each group and compute the mean for that set when the group/wave number changes and save that value in array to use for xticks argument. Then you will use the unique categorical variable as labels instead of the full X array.
The above initial step gets to this point --
Well, OK, I lied... :) Couldn't stand it!!!
The modifications are --