Original Matlab code to calculate loss segments used for transmission electrical losses in SPD