I am running autonomous underwater vehicle missions which give me lat, long, depth, and temperature data that I am trying to create 3D interpolations with. I am able to create the 3D model of the environment but I am trying to have the color fill be the interpolated temperature at each associated position.
The image below is the 3d depth chart I get that I want to have the fill color be the temperatures at those locations:
I have tried using colormap where surf(X, Y, Z, C) and C is the temperature data but that does not work.
This is what I have for code where VPSA is my data set and X = longitude, y = latitude, Z = depth, and C = temperature
%Making Variables:
X = VPSA {:,1};
Y = VPSA {:,2};
Z = VPSA {:,3};
C = VPSA {:,4};
%Three axis plot
%Plotting Variable with coordinates
xi = linspace(min(X),max(X),1000);
yi = linspace(min(Y),max(Y),1000);
[Xi,Yi] = meshgrid(xi,yi);
Zi = griddata(X,Y,Z, Xi,Yi);
mesh (Xi,Yi,-Zi)
xlabel('Latitude')
ylabel('Longitude')
zlabel('Depth')
UPDATE: I added the following lines of code
Ci = griddata(X,Y,C,Xi,Yi);
mesh(Xi,Yi,-Zi,Ci)
to get the following figure, but it is so hard to tell what is going on, I wonder if there is a way to smooth the interpolation out into a box so it isn't as jagged.
Thank you!!
I am assuming that the original X,Y,Z,C
data points are matched, and you can use the command mesh(X,Y,Z,C)
to get a usable plot. Now you are looking to do the same, but with an interpolated dataset.
In this case, you only need to give the mesh
command a the color data C
.
C
also needs to be interpolated, so maybe something like:
Ci = griddata(X,Y,C,Xi,Yi); % Interpolate C the same way you did for Z
mesh(Xi,Yi,-Zi,Ci)
Edit: Apologies for the previous incorrect answer.