Just change
if(mx==iDataX[z])
to
mx=iDataX[z];
and lose the else clause.

You don't need an if at this point because if(my==iDataY[z]) already removes all cases where there isn't a * to plot. So all you need to do within this if is to look up the value of iDataX[z] and draw the * in the appropriate place.