interp3 problem
1 回表示 (過去 30 日間)
古いコメントを表示
I have a dataset as below, named it as "a" in Matlab.
46.567 -111.28 2423.2 -1.2006
45.883 -110.93 2231.1 0.7962
46.783 -109.52 1844.0 2.898
46.667 -110.33 2316.5 -0.21062
46.800 -110.68 1966.0 0.12335
45.70 -110.45 1456.0 7.9804
45.767 -111.15 1398.0 2.0
46.917 -110.85 2258.6 -0.39873
46.583 -111.27 2026.9 1.20
46.117 -110.47 1981.2 3.4545
46.083 -110.43 2468.9 0.11388
45.867 -110.93 1996.4 1.9115
46.783 -110.62 2468.9 -1.4
46.90 -110.90 1996.4 0.71936
the first column are Lat, Lon, Elevation and temperature. Now I want to use these data to do the interp3 in matlab. I write the code:
% original data
x=a(:,2);
y=a(:,1);
z=a(:,3);
[X,Y,Z]=meshgrid(x,y,z);
[r,m,n]=size(X);
V=zeros(r,m,n);
for i=1:r
V(:,:,i)=a(i,4);
end
% the location for interp3 U_lat=46.958346;
D_lat=46.891312;
L_lon=-110.907516;
R_lon=-110.836179;
xi=L_lon:0.0005:R_lon;
yi=D_lat:0.0005:U_lat;
zi=1950:5:2500;
[Xi,Yi,Zi]=meshgrid(xi,yi,zi);
% do the interp3
Vi=Vi=interp3(X,Y,Z,V,Xi,Yi,Zi);
and error show as:
??? Error using ==> interp3 at 172 X, Y, and Z must be monotonic vectors or arrays produced by MESHGRID.
I don't know if the data organization of X,Y,Z,V,Xi,Yi and Zi is right or not. It always shows this error message. Any help is greatly appreciated! Thanks!
0 件のコメント
回答 (1 件)
Honglei Chen
2011 年 10 月 27 日
For interp3 to work, the data must be in a grid. However, from the data you show, it seems that they are not really sampled in a grid, i.e., the data is not always sampled in the same Lat, Lon, and Altitude. In this case, you may want to try TriScatteredInterp, somewhat like this.
F = TriScatteredInterp(x,y,z,v)
Vi = F(Xi,Yi,Zi)
check the doc for details.
doc TriScatteredInterp
HTH
参考
カテゴリ
Help Center および File Exchange で Data Preprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!