フィルターのクリア

extract value at a specific location

1 回表示 (過去 30 日間)
Meriem Deli
Meriem Deli 2016 年 11 月 25 日
回答済み: Meriem Deli 2016 年 11 月 28 日
Hello,
I am trying to extract a value at a specific point based on its latitude and longitude, I have a Temperature matrix(from a netcdf file) at different latitude and longitude I should get Temperature at a specfic location that is not figuring in the matrix I tried with interp2:
Tst=interp2(T1,lon_desired,latitude-desired)
but I get NaN
Could someone help me fix this issue.
Thanks in advance

採用された回答

dpb
dpb 2016 年 11 月 25 日
Tst=interp2(T1,lon_desired,latitude-desired)
Don't supply the coordinates of the reference T array so the values requested are outside the ranges 1:N,1:M, the dimensions of the array T1 undoubtedly. See the doc for usage details; you need the first syntax shown.
  2 件のコメント
dpb
dpb 2016 年 11 月 25 日
[Moved OP Answer to Comment...dpb]
I tried to put original latitude and longitude but I got an error:
>> Tstat=interp2(longitude,latitude,T1,lon,lat)
Error using griddedInterpolant
The grid vectors do not define a grid of points that match the given values.
Error in interp2>makegriddedinterp (line 226)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 136)
F = makegriddedinterp(X, Y, V, method,extrap);
I don't know what is the problem with that syntax
dpb
dpb 2016 年 11 月 25 日
編集済み: dpb 2016 年 11 月 26 日
Isn't the syntax, per se, it's the data.
From the doc,
"X and Y must be monotonic, and have the same format ("plaid") as if they were produced by meshgrid. Matrices X and Y specify the points at which the data Z is given."
Hence, X,_Y_ must have same dimensions 1:1 as does Z (your T1). If you don't have regular, full-rank MxN array(), you can't use *interp2. If that is so, then perhaps griddata will suffice.
(*) It's possible with lat/long data it's full array but may not be organized such that it's not arranged in "plaid" order.

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 11 月 25 日
You need to pass in the original latitude and longitude vectors as the first two arguments to interp2(). Currently you are just passing in the data matrix without giving any indication of what latitude or longitude the rows and columns correspond to.

Meriem Deli
Meriem Deli 2016 年 11 月 28 日
griddata was a solution, In fact I tried it before and I got an error because I forget to put tranpose T, Thank you all for your help.

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by