Effacer les filtres
Effacer les filtres

error using interp2

25 vues (au cours des 30 derniers jours)
kristian stokkereit
kristian stokkereit le 20 Août 2021
Commenté : Chunru le 21 Août 2021
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

Réponses (1)

Chunru
Chunru le 20 Août 2021
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 commentaires
kristian stokkereit
kristian stokkereit le 20 Août 2021
Modifié(e) : kristian stokkereit le 20 Août 2021
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 le 21 Août 2021
typo. it should be "provide".

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by