Issues with "interp2" in MatLab, 2-d data interpolation

7 views (last 30 days)
I am trying to use "interp2" to fill in values of a dataset (chlorophyll data) with missing (Nan) points. I have four datasets I am working with: land points (1x3744), chlorophyll data (144x3744), latitude (1x3744), and longitude (1x3744). For the chlorophyll data, the rows are time and the columns are space. I have tried to reshape all the data into matrices but I keep getting errors and can't figure out how to appropriately prepare these to use "interp2" successfully.
  5 Comments
Matt J
Matt J on 20 Feb 2013
And copy/pastes of the exact error messages.
Maureen
Maureen on 21 Feb 2013
>> land2=reshape(land,72,52);
>> lon2=reshape(lon,72,52);
>> lat2=reshape(lat,72,52);
>> a=reshape(xnew(1,:),72,52);
>> lon2(land)=nan;
>> lat2(land)=nan;
>> lon2=reshape(lon,72,52);
>> lat2=reshape(lat,72,52);
>> a(land)=nan;
>> ZI = interp2(lon2,lat2,a,lon2,lat2);
??? Error using ==> interp2 at 155 X and Y must be matrices produced by MESHGRID. Use GRIDDATA instead of INTERP2 for scattered data.
>> ZI = griddata(lon2,lat2,a,lon2,lat2);
??? Error using ==> qhullmx The first input argument must be a double array.
Error in ==> delaunayn at 117 t = qhullmx(x', 'd ', opt);
Error in ==> griddata>linear at 150 tri = delaunayn([x y]);
Error in ==> griddata at 119 zi = linear(x,y,z,xi,yi,opt);
>> ZI = griddata(double(lon2),double(lat2),double(a),double(lon2),double(lat2));

Sign in to comment.

Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!