General transformation for block diagonalization of weakly coupled linear systems composed of N-subsystems