MATLAB: Why interp2 report “input grid is not a valid meshgrid” since input grid is generated by meshgrid

interpolationMATLAB

Dear Community,
I need to do a 2D interpolation for a matrix data, but when I use the interp2, the function report error "input grid is not a valid meshgrid". I am really confused since the input grid is generated by meshgrid function. If anyone knows this issue, could you please give me some suggestions?
% original coordinate
je=167;
ke=117;
dy=4e-8;
dz=dy;
ya=[0:dy:je*dy];
za=[0:dz:ke*dz];
ya=ya-mean(ya);
za=za-mean(za);
% interpolation
load data.mat
[Z,Y]=meshgrid(za,ya);
aymap = interp2(Y,Z,ay,squeeze(newcord_Y),squeeze(newcord_Z));

Best Answer

load("data.mat") ;
% original coordinate
je=167;
ke=117;
dy=4e-8;
dz=dy;
ya=[0:dy:je*dy];
za=[0:dz:ke*dz];
ya=ya-mean(ya);
za=za-mean(za);
% interpolation
load data.mat
[Zi,Yi]=meshgrid(za,ya);
Y = squeeze(newcord_Y) ;
Z = squeeze(newcord_Z) ;
aymap = interp2(Y,Z,ay,Yi,Zi);