more off

Version='interpn_bug' ; % 'interpn' or 'interpn_bug'

%% variables in polar coords
phi=0:10:90 % degree
r=0:1:10 

[PHI,R]=meshgrid(phi,r)

%% define an example function
Z=0.1*R.^2;

%% variables in cartisian coords
x=0:10
y=x
[X Y]=meshgrid(x,y);

%% coord-transformation from cartisian to polar coords
iR=sqrt(X.^2+Y.^2);
iPHI=atan(Y./X)/pi*180;
iPHI(1,1)=0;

switch (Version)
  case 'interpn_bug'
    iZ=interpn(R,PHI,Z,iR,iPHI,'spline');
  case 'interpn'
    iZ=zeros(size(iPHI)); % workaround for bug in interpn
    iZ(:)=interpn(R,PHI,Z,iR(:),iPHI(:),'spline');
end

mesh(X,Y,iZ)

