# grid non monotonic XYZ arrays

6 vues (au cours des 30 derniers jours)
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

dbmn le 28 Juil 2017
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;
hdl.EdgeAlpha = 0.5; % makes lines slightly transparent
This gives you something like this:
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
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.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by