필터 지우기
필터 지우기

error using interp2

조회 수: 25 (최근 30일)
kristian stokkereit
kristian stokkereit 2021년 8월 20일
댓글: Chunru 2021년 8월 21일
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

답변 (1개)

Chunru
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
kristian stokkereit
kristian stokkereit 2021년 8월 20일
편집: kristian stokkereit 2021년 8월 20일
Sorry, what does 'prived' mean? Also I changed it to griddata an that appears to have fixed the issue. Thank you very much.
Chunru
Chunru 2021년 8월 21일
typo. it should be "provide".

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by