필터 지우기
필터 지우기

How can I interpolate different dimension array on a common grid?

조회 수: 6 (최근 30일)
Federico
Federico 2013년 12월 14일
댓글: dpb 2013년 12월 19일
Hi everybody,
I find myself with spatialized data coming from different sources that I'd like to compare by interpolating them on a common grid, but I still don't understand how.
I have two sets of data of Longitude, Latitude, Altitude and a scalar value: in the first set all of these variables are vectors (1 row * n columns), while in the second set they are n-dimensional matrixes (for Longitude I have a matrix of m rows * n column * p layers having a longitude value for each [m,n,p] point in this "cube", the same goes for Latitude, ...).
I would like to use the minima and maxima of values of Longitude, Latitude and Altitude to create a common 3D grid on which to interpolate the scalar values.
I can give an example of two different datasets and the steps I did until now along with how I used Matlab's grid interpolation functions (dataset values are purely fictional and way much bigger, it's just to have an example).
Dataset 1:
Lon = [-0.98 -0.97 -0.96] % degrees
Lat = [44.1 44.2 44.3] % degrees
Alt = [380 400 450] % meters
Scal = [22.2 35 40] % concentration
Dataset 2:
Lon=[-0.982 -0.981;-0.980 -0.975;-0.970 -0.965] % degrees
Lat= [44.09 44.10;44.11 44.22;44.24 44.23] % degrees
Alt(:,:,1)= [320.2 330;327 350;322 327] % meters
...
Alt(:,:,4)= [470 447.1;475 480;477 450] % meters
% Again Scal is a m*n*p matrix where p is equal to 4.
Since Dataset 2 is the one with the most widely spanning data, I've constructed a grid on the basis of those data using ndgrid:
MinLat=min(min(Lat));
MaxLat=max(max(Lat));
StepLat=abs(MaxLat-MinLat)/100;
MinLon=min(min(Lon));
MaxLon=max(max(Lon));
StepLon=abs(MaxLon-MinLon)/100;
MinAlt=min(min(Alt(:,:,1));
MaxAlt=max(max(Alt(:,:,3));
StepAlt=abs(MaxAlt-MinAlt)/100;
LonQueryPoints=MinLon:StepLon:MaxLon;
LatQueryPoints=MinLat:StepLat:MaxLat;
AltQueryPoints=MinAlt:StepAlt:MaxAlt;
Grid=ndgrid(LonQueryPoints,LatQueryPoints,AltQueryPoints);
Grid is now a 100*100*100 matrix made by the query points of Longitude, Latitude and Altitude and it's where I'd like to interpolate my scalar values and I've tried it using the "griddedInterpolant" Matlab function:
% Applied to Dataset 2:
Scalar_Interpolation=griddedInterpolant(Grid,Scal(:,:,1:4))
And I receive the error:
1D Interpolation requires vector input for X and V
Probably I'm not understanding correctly how to employ the griddedInterpolant function, or, maybe, the griddedInterpolant is only able to handle m*n*1 matrixes.
  댓글 수: 6
Federico
Federico 2013년 12월 17일
편집: Federico 2013년 12월 17일
The thing is that Dataset 1 is made of field observations of a scalar (made at different Lon/Lat/Alt) and Dataset 2 is made by values of the same scalar but outputted by a model (at different Lon/Lat/Alt): I'd like to be able to interpolate them on a common grid so that, in the end, I'm able to say that the model is correctly evaluating the scalar (or not) and what's the difference, for example, in terms of RMSE between the two.
The problem with interp3 is that
The grid vectors are not strictly monotonic increasing
dpb
dpb 2013년 12월 19일
See the other thread I mentioned wherein the input values were rearranged in ascending order--seems same idea should work here.

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

답변 (0개)

카테고리

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