Rearranging matrix for interpolation and the problem of memory
Show older comments
Hi,
I want to interpolate data onto satellite tracks using the following code:
for day = 1:size(ssh_int,1);
mask(:,:,day) = mask50;
ma = permute(mask,[3 1 2]);
%f = ndgrid(ma);
m50m(:,:,day)=interp2(lonrep,latrep,squeeze(mask(:,:,day)),REF_lon,REF_lat,'linear
With lonrep and latrep being the repeated matrices of lon and lat from the mask. Both of which are 3600 x 1682. mask is 3600 x 1682 x 365. REF_lon/lat are 3127 x 254 (satellite index & arcs).
However, I get the following error message:
Error using griddedInterpolant
Data is in MESHGRID format, NDGRID format is required. Convert your data as follows: X = X'; Y = Y'; V = V'; F = griddedInterpolant(X,Y,V)
Error in interp2/makegriddedinterp (line 220) F = griddedInterpolant(varargin{:});
Error in interp2 (line 133) F = makegriddedinterp(X, Y, V, method);
Error in depth_criterion (line 52) m50m(:,:,day)=interp2(lonrep,latrep,squeeze(mask(:,:,day)),REF_lon,REF_lat,'linear');
From another question I asked related to this one, I got an answer that the data should be sorted monotonically.
I have tried usind code like
ndgrid(blahh)
or
meshgrid(blahh)
or
sort(blahh)
but to no provail. I am fairly new to matlab so I still don't understand fully the wording usually used.
Can someone please help me?
also, I keep getting memory error messages. Are there any good tips to get around this? currently, I use t = ones(matrix) method or x NaN's or by deleting large variables after usage. I always get this messages when dealing with 3D matrices...
thanks, Michael
Accepted Answer
More 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!