  Mutually orthogonal complementary sets (MOCSs) and Z-complementary code sets
(ZCCSs) have many applications in practical scenarios such as synthetic
aperture imaging systems and multi-carrier code division multiple access
(MC-CDMA) systems. With the aid of extended Boolean functions (EBFs), in this
paper, we first propose a direct construction of MOCSs with flexible lengths,
and then propose a new construction of ZCCSs. The proposed MOCSs cover many
existing lengths and have non-power-of-two lengths when q = 2. Our presented
second construction can generate optimal ZCCSs meeting the set size upper
bound. Note that the proposed two constructions are direct without the aid of
any special sequence, which is suitable for rapid hardware generation.
