plotting three column vectors (lat,long,temp) on a contour plot

1 次查看(过去 30 天)
I have three column vectors (lat,long,temp) referred to as F(:,1) F(:,2) and F(:,3). I would like to make a contour plot. I process the data:
if true
% code
end
x = F(:,1);
y = F(:,2);
z = F(:,3);
xi=linspace(min(x),max(x),30)
yi=linspace(min(y),max(y),30)
[XI YI]=meshgrid(xi,yi);
ZI = griddata(x,y,z,XI,YI);
contourf(XI,YI,ZI)
As you can see I created the query points and it should function. However, I get this error: Error using scatteredInterpolant The input points must be a double array.
Error in griddata>useScatteredInterp (line 184) F = scatteredInterpolant(inargs{1}(:),inargs{2}(:),inargs{3}(:), ...
Error in griddata (line 125) vq = useScatteredInterp(inputargs, numarg, method, 'none');
It seems matlab wanted me to use scatteredInterpolant rather than griddate so I tried:
if true
% code
end
F = scatteredInterpolant(lon2,lat2,temp2);
[xx,yy]=meshgrid(lon2,lat2);
zz = F(xx,yy);
contour(xx,yy,zz)
surf(xx,yy,zz)
and I got the error: Error using scatteredInterpolant The input points must be a double array.
if true
% code
endcontour(lon2,lat2,temp2);
Error using contour (line 53) Z must be at least a 2x2 matrix.
>>
if true
% code
endmesh(lat2,lon2,temp2);
Error using mesh (line 75) Z must be a matrix, not a scalar or vector.
if true
% code
end
tri = delaunay(x,y);
trisurf(tri,x,y,z)
Error using delaunay The input points must be a double array.
It seems that I cannot use a vector for my z values - it must be a matrix? I have not run into this problem before and I don't know how to convert my third column of z values into a geo-referenced matrix. Can anyone help me out?
It may be important to mention that I am using matlab 2016. I have previously used griddata in 2011 with 3 column vectors and I didn't have a problem.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by