MATLAB: How to set axis as -pi to pi

horn antenna rad pattern

Hi. I have attached my program for the radiation pattern of the horn antenna. I want to have a graph which should have axis from -pi to pi. but I cant do it. When I use set(gca,'XTick',-pi:pi/2:pi) set(gca,'XTickLabel',{'-pi','-pi/2','0','pi/2','pi'}) command, the figure appears to be some what like I have attached. Please help.

Best Answer

Leena, in the code you are converting the angels (x-axis) from rad to deg. Also it seems like the angular range is between 0 and 360 deg. Therefore,
  • remove the conversion factor, e.g., e = theta, or simply use theta for plotting,
  • and set
set(gca,'XTick',0:pi/2:2*pi)
set(gca,'XTickLabel',{'0','pi/2','pi','3*pi/2','2*pi'})