% This function generates a pcolor image in polar co-ordinates.

function PolarPcolorWeili(sita,radius,sigma,rmedia,n2,nthe,nrr)
ppx=radius.'*cos(sita);
ppy=radius.'*sin(sita);
figure('position',[300 100 380 320]);%set the position and size of the figure
set(gca,'Position',[.040 .07 .85 .85]);% set the position and size of the main plot zone
pcolor(ppy,ppx,sigma);
shading interp;
colorbar;
set(colorbar, 'Position', [.905 .2 .026 .6150]);% set the size and position of the colorbar
axis square;
set(gca,'xticklabel',{-rmedia, -rmedia/2.0, 0, rmedia/2.0, rmedia});
set(gca,'xticklabel',{-rmedia, -rmedia/2.0, 0, rmedia/2.0, rmedia});
axis off;
hold on
% plot and label the radial co-ordinates
for i= 1:nthe
    rrrbh=rmedia/nthe*i*ones(1,n2);
    polar(sita,rrrbh,'-black');
    if (i==nthe)
        formatx= '%3.2f m';
    else
        formatx= '%3.2f';
    end
    xnum= round(rmedia/nthe*i,2);
    str= sprintf(formatx,xnum);
    text(0.01,rmedia/nthe*i-0.05,str);
end
% plot and label the azimuthal co-ordinates
for i= 1:nrr
    plot([0,rmedia*sin(2*pi/nrr*(i-1))],[0,rmedia*cos(2*pi/nrr*(i-1))],'-black');
    formatx= '%d^{o}';
    xnum= int16(360/nrr*(i-1));
    str= sprintf(formatx,xnum);
    if ((i-1)/nrr*360==0)
        text(1.05*rmedia*sin(2*pi/nrr*(i-1)),1.08*rmedia*cos(2*pi/nrr*(i-1)),str);
    end
    if ((i-1)/nrr*360>0 && (i-1)/nrr*360<45)
        text(1.1*rmedia*sin(2*pi/nrr*(i-1)),1.05*rmedia*cos(2*pi/nrr*(i-1)),str);
    end
    if ((i-1)/nrr*360>=45 && (i-1)/nrr*360<180)
        text(1.05*rmedia*sin(2*pi/nrr*(i-1)),1.05*rmedia*cos(2*pi/nrr*(i-1)),str);
    end
    if ((i-1)/nrr*360<=300 && (i-1)/nrr*360>=240)
        text(1.2*rmedia*sin(2*pi/nrr*(i-1)),1.05*rmedia*cos(2*pi/nrr*(i-1)),str);
    end
    if ( ((i-1)/nrr*360>300 && (i-1)/nrr*360<=315) || ((i-1)/nrr*360>=225 && (i-1)/nrr*360<240) )
        text(1.26*rmedia*sin(2*pi/nrr*(i-1)),1.05*rmedia*cos(2*pi/nrr*(i-1)),str);
    end
    if ( ((i-1)/nrr*360>315 && (i-1)/nrr*360<360) || ((i-1)/nrr*360>=180 && (i-1)/nrr*360<225) )
        text(1.42*rmedia*sin(2*pi/nrr*(i-1)),1.05*rmedia*cos(2*pi/nrr*(i-1)),str);
    end
end
colormap(jet);% set the type of colorbar
hold off