Determine matrix positions for each sex, shell, mat stage, and loop over.