Interpolating data to get values at specific depth
Mostrar comentarios más antiguos
Dear experts, please help. I was searching and trying for anentire day and I couldn't figure it out by my own.
I have X, Y, Z, data.
X is longitude, Y is latitude, Z is depth, and data is temperature for example.
X and Y are 2D matrices (224x164). Z and data are 3D matrices (224x164x37).
The depth is unevenly spaced, for exemple, 1.0, 2.3, 5.6, 8.3 and so on, but I need the values of temperature exactly at 5m for example.
What I need is to get the data values at a specif depth all over the domain to plot a colored 2D map.
Please, could someone help me on how is such interpolation?
P.S. I know how to plot, I did it by plotting the surface Z(:,:,1), but as I mentioned, I need other depth layer.
Thank you so much in advance!
Respuesta aceptada
Más respuestas (1)
x=(0:10); y=(0:11)'; z=[1.0, 2.3, 5.6, 8.3]; % vectors x,y,z
[X,Y]=meshgrid(x,y);
%Make data() with desired dimensions, same at each depth
data=repmat(sin(2*pi*y/11)*cos(2*pi*x/10),[1,1,length(z)]);
% Make data different at different depths
for k=1:length(z), data(:,:,k)=data(:,:,k)+z(k)^2/10; end
% check that the array sizes are as desired
fprintf('Size X, Y, Z= %dx%d, %dx%d, %dx%dx%d.\n',size(X),size(Y),size(data))
% Plot data(x,y,z=5.6), as a test
surf(X,Y,data(:,:,3));
grid on; xlabel('X'); ylabel('Y'), zlabel('Data'); title('Data(:,:,z=5.6)')
data5=zeros(size(X)); % allocate array for data interpolated to z=5
for i=1:length(y), for j=1:length(x)
data5(i,j)=interp1(z,squeeze(data(i,j,:)),5);
end, end
% Plot data(x,y,z=5)
surf(X,Y,data5);
grid on; xlabel('X'); ylabel('Y'), zlabel('Data');
title('Data, Interpolated to z=5')
OK
Categorías
Más información sobre Interpolation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



