Gain Margin Matlab, I used the below code to calculate the gain and phase margin.