3D interpolation using Griddata
45 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Telema Harry
am 23 Jun. 2023
Bearbeitet: Telema Harry
am 23 Jun. 2023
I have a 3D gridded data. The 3D grid is partitioned as:
a = [0.25, 0.5, 0.75];
b = [0.25, 0.5, 0.75];
c = [1,2,3];
[A,B,C] = meshgrid(a,b,c);
We have data at each grid point. The data is given by:
Arr = [1 2 3; 4 5 6; 7 8 9] ;
Arr(:,:,2) = [10 11 12; 13 14 15; 16 17 18];
Arr(:,:,3) = [15 16 17; 18 19 20; 21 22 23];
I would like to interpolate the data(Arr) along the C axis, at 2.5.. Please, how can I do that?
0 Kommentare
Akzeptierte Antwort
Rahul
am 23 Jun. 2023
According to the information shared, you currently have 3D gridded data and data at each grid point. You are further trying to interpolate the data at each point along the z-axis with a value of 2.5. This can be done by using interp3 function in the following way.
% Given data
a = [0.25, 0.5, 0.75];
b = [0.25, 0.5, 0.75];
c = [1, 2, 3];
[A, B, C] = meshgrid(a, b, c);
Arr = [1 2 3; 4 5 6;7 8 9];
Arr(:, :, 2) = [10 11 12; 13 14 15;16 17 18];
Arr(:, :, 3) = [15 16 17; 18 19 20; 21 22 23];
% Interpolate along the C axis at 2.5
interp_value = 2.5;
Now you need to query coordinates matching the size of A, B, and C in the following way.
[Xq, Yq, Zq] = meshgrid(a, b, interp_value);
Now after obtaining the meshgrid along different axis and query coordinates with the new interpolated mesh grid information, we can interpolate the available data at each grid point using interp3 function like,
interpolated_result = interp3(A, B, C, Arr, Xq, Yq, Zq);
disp(interpolated_result);
You can find more information about interp3 function from below given resources. Thanks.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!