grid non monotonic XYZ arrays

1 次查看(过去 30 天)
Hi there,
I am have a bunch of data sets that correspond to scientific measurements along an ocean transect collected by an Ocean Glider.
  • X data is uniform increasing and represents distance (range).
  • Y data is increasing and decreasing (zi-zag like) and represents the various dive states of the vehicle as it progresses the distance or time. (Vehicle dives down and up to surface in a zig zag pattern.)
  • Z data corresponds to those X, Y coordinates.
My goal is to grid the data on a 1000x1000 grid representing range in the X axis (100km), and depth in the Y axis (1000m) in order to interpolate/plot the data on the new grid. The data arrays are sometimes more than 56 000 rows per vector long.
So far the best working solution I have is to use MATLAB's fit function to the X,Y,Z data using a liner interpolation. However when sampling the data from the fit object (surface), the resulting grid is not very smooth.
Does anyone have some suggestions on how to produce a smooth contour from the data I have? All my data should be reasonably stratified across depth, producing relatively smooth lines.

回答(1 个)

dbmn
dbmn 2017-7-28
I assume you want to plot that data.
Well the most obvious way would be to just plot the lines with
plot3(Xout, Yout, Zout);
But that might not satisfy your needs...
So lets do something different
% 1. Create a grid
% 1.1 for that create grid vectors of your choice
x = [0:100];
y = [0:10:1000];
% 1.2 Create a 2D Grid of these vectors (please not that X ist not equal to x)
[X,Y] = meshgrid(x,y);
% 2. Interpolate
% 2.1 no need to use fit, simply do that with
Z = griddata(Xout,Yout,Zout,X,Y);
% 3. Plot
hdl = surf(X,Y,Z);
% 4. Make the figure nicer, f.ex
ax = gca;
ax.CLim = [3.2, 3.7]; % adjusts the colorbar to your needs
hdl.EdgeAlpha = 0.5; % makes lines slightly transparent
This gives you something like this:
  1 个评论
Nicolai von Oppeln Bronikowski
Hi there,
Thanks for trying. Unfortunately griddata does not represent the top depth layer well.
If you have any other/further thoughts on how to deal with the sudden changes in values of temperature please let me know. I have been trying without much luck to interpolate the values over an even grid without to get rid of the squished changes in temperature.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by