A Unified Procedure for Deriving the Differential Equations of Electrical and Mechanical Systems