The averaging method for control design and stability analysis of practical switched systems