There is a major discontinuity in the middle of the longitude data, that makes interpolation impossible. Lets find it:
>> median(diff(lat_model))
ans =
0.9424
>> all(0<diff(lat_model))
ans =
1
>> median(diff(lon_model))
ans =
1.2500
>> all(0>diff(lon_model))
ans =
0
>> tmp = diff(lon_model);
>> find(tmp<0)
ans =
145
>> lon_model(140:150)
ans =
173.7500
175.0000
176.2500
177.5000
178.7500
180.0000
-178.7500
-177.5000
-176.2500
-175.0000
-173.7500
Wow... it jumps from +180 to -178.75, in the middle of a monotonic increasing sequence.
How to deal with this is up to you, and depends on what the data represents. If these are degrees you may be able to convert them to the positive equivalents:
idx = lon_model<0;
lon_model(idx) = 360 + lon_model(idx);
You should also remove that transpose from first_model, which will cause another error. This code works without error:
load data
idx = lon_model<0;
lon_model(idx) = 360 + lon_model(idx);
[X, Y] = meshgrid(lat_model, lon_model);
[Xq, Yq] = meshgrid(lat, lon);
Serna_approx = interp2(X, Y, first_model, Xq, Yq);
although this is not proof that it does what want it too
Best Answer