Interpolating from one grid to another

49 ビュー (過去 30 日間)
Luís Henrique Bordin
Luís Henrique Bordin 2024 年 4 月 5 日 18:11
コメント済み: Star Strider 2024 年 4 月 23 日 14:38
Hello experts
Please, could someone help me with an interpolation?
I have two different 2D scattered grids (X = longitude, Y = depth), and a variable temperature, from two different datasets. On the first one x and y are 41x37, and on the second 24x10. Also Temp1 (41x37) and Temp2 (24x10).
I need to compute the difference (Temp1 - Temp2), but for that, I need Temp2 to be on the same format (and coordenates) as Temp1, that is, 41x37. Then, I guess I have to interpolate X2, Y2, Temp2, to the coordinates of X1, Y1.
I tried scatteredInterpolant function, but I it doesn't work, moreover, it does not allow me to inform the reference coordinates, that is, X1,Y1.
Both scatteredInterpolant and TriScatteredInterp has the structure F = function(x,y,v), but I need something like NewTemp2 = function(X1,Y1,X2,Y2,Temp2).
Please, could someone help me with this?
The data is attached, thank you very much in advance!

採用された回答

Star Strider
Star Strider 2024 年 4 月 5 日 18:32
編集済み: Star Strider 2024 年 4 月 5 日 18:34
It appears that ‘Temp1’ seems to not have made it to the save function argument llist.
This interpolates ‘Temp2’ to the (X1,Y1) grids using scatteredInterpolant
load('data.mat')
whos
Name Size Bytes Class Attributes Temp2 24x10 1920 double X1 41x37 12136 double X2 24x10 1920 double Y1 41x37 12136 double Y2 24x10 1920 double ans 1x32 64 char cmdout 1x33 66 char gdsCacheDir 1x14 28 char gdsCacheFlag 1x1 8 double i 0x0 0 double managers 1x0 0 cell managersMap 0x1 8 containers.Map
figure
surfc(X2, Y2, Temp2)
grid on
xlabel('X2')
ylabel('Y2')
zlabel('Temp2')
X2Y2 = [X2(:), Y2(:)];
X2Y2(isinf(X2Y2)) = NaN;
X2Y2 = fillmissing(X2Y2, 'linear');
X2v = X2Y2(:,1);
Y2v = X2Y2(:,2);
FTemp2 = scatteredInterpolant(X2v(:), Y2v(:), Temp2(:));
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
Temp2i = FTemp2(X1, Y1);
figure
surfc(X1, Y1, Temp2i)
grid on
xlabel('X1')
ylabel('Y1')
zlabel('Temp2 — Interpolated To (‘X1,Y1’)')
Do the same sort of approach to interpolate ‘Temp1’ to the ‘Temp2’ grids, if necessary.
EDIT — Corrected typographical errors.
.
  13 件のコメント
Luís Henrique Bordin
Luís Henrique Bordin 2024 年 4 月 23 日 14:29
Okay. Thank you very much, have a good day!
Star Strider
Star Strider 2024 年 4 月 23 日 14:38
As always, my pleasure!
You, too!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by