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.
0 个评论
回答(1 个)
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:
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!