error using interp2
25 次查看(过去 30 天)
显示 更早的评论
I am trying to interpolate a large array of points onto a regular grid. I have a large array called fld1intsty of size 320723x3 double the first, second and third clumns correspond to the x,y and z axes respectively; also, the first column values are distributed between 1.0 and 601.0 whilst the second column values are distributed between 0.0 and 0.8. I have tried to this onto a grid defined spaced with 1.0 and 0.01 in the x and y directions respectiely with the same upper and lower limits.
dx = 1.0;
dy = 0.01;
xi = 1.0:dx:601.0
yi = 0.0:dy:0.8
[XI,YI] = meshgrid(xi,yi);
field1 = interp2(fld1intsty(:,1),fld1intsty(:,2),fld1intsty(:,3),XI,YI);
When I do this I get an error at line 100 (the line starting with field) saying the folloing:
Error using griddedInterpolant
Interpolation requires at least two sample points for each grid dimension.
Error in interp2>makegriddedinterp (line 226)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 126)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in full_band (line 100)
field1 = interp2(fld1intsty(:,1),fld1intsty(:,2),fld1intsty(:,3),XI,YI);
I do not understand what I am doing as the input fields obviously match in size because they are from the same array. Any help would be appreciated, if not in the form of an explanation, then a straight fix would also be great. Also I know that questions like this have been asked already but I found them more confusing than helpful. Thank you
0 个评论
回答(1 个)
Chunru
2021-8-20
Looks like you should use "griddata" instead of "interp2" when you have irregular data points (x,y,z). "doc griddata" for details. Otherwise prived some data.
2 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!