function [thetav,rhov] = cart2cyluv(u,v,thetai,rhoi,varargin) % z=cart2cyl(c,xi,yi); % NN=size(u); [x y nz]=size(u); stepx=(x+1)/(x); stepy=(y+1)/(y); [Y,X] = meshgrid(-(x)/2:stepx:(x)/2,-(y)/2:stepy:(y)/2); [theta,rho] = cart2pol(X,Y); % switches to increasing c-clockwise instead of clockwise theta=-theta; %original %azimv=u.*cos(theta)+v.*-sin(theta); %radialv=u.*sin(theta)+v.*cos(theta); % 2nd try %azimv=u.*cos(theta)+v.*sin(theta); %radialv=u.*sin(theta)+v.*-cos(theta); %azimv=u.*-cos(theta); %good %radialv=u.*-sin(theta);%good %azimv=v.*-sin(theta); % good %radialv=v.*cos(theta); % good % 3rd's the charm azimv=u.*-cos(theta)+v.*-sin(theta); radialv=u.*-sin(theta)+v.*cos(theta); theta=(theta./(pi*2)+0.5).*(size(thetai,2)); rho=max(rhoi)*rho/((x)/2); ntheta=x;nrho=y; THETA=reshape(theta,[1 ntheta*nrho]); RHO=reshape(rho,[1 ntheta*nrho]); del=griddata_preprocess(RHO,THETA,rhoi,thetai',varargin{:}); for k=1:nz; THETAV=reshape(azimv(:,:,k),[1 ntheta*nrho]); RHOV=reshape(radialv(:,:,k),[1 ntheta*nrho]); thetav(:,:,k)=griddata(RHO,THETA,THETAV,rhoi,thetai',varargin{:}); rhov(:,:,k)=griddata(RHO,THETA,RHOV,rhoi,thetai',varargin{:}); end % k % Split vertical and time dimensions if size(NN,2)>2 thetav=reshape(thetav,[size(thetav,1) size(thetav,2) NN(3:end)]); rhov=reshape(rhov,[size(rhov,1) size(rhov,2) NN(3:end)]); end