# Creating a 3d volumetric matrix for irregular xyz data with multiple depths

10 vues (au cours des 30 derniers jours)
Jenny le 9 Août 2014
I'm trying to turn an irregular 3d dataset into a regular dataset so I can average the values - and produce an average cross-section.
I have an irregular grid of nodes, with each node have 20 depth temperature values with each node having these taken at different depths. So each node has 20 readings for it's depth, though they're not at the same heights for each node.
This is an overview of the nodes, which is a top down view of the river channel.
-------------------------------------------------------------------------
I've been advised to try using scatteredinterpolant or interp3 but I'm having issues because I'm not sure how to use this for a 'z' which is not a single value but a vector of the different heights.
I'm also not sure if/how I should be using mesh grid and if I should be using it before I try to use interp3.
Right now I have the variables
• xnode (1x54) - (x coordinate of nodes)
• ynode (1x54) - (y coordinate of nodes)
• depthsatnode (20x54) - depths of the 20 variables at each of the 54 nodes
• tempatnode (20x54) - temperature of the 20 heights at each of the 54 nodes
-------------------------------------------------------------------------
Feeling quite out of my depth here - any advice on how to approach the coding of this greatly appreciated!
##### 2 commentairesAfficher AucuneMasquer Aucune
Image Analyst le 9 Août 2014
For background, the earlier/duplicate one is here.
Jenny le 9 Août 2014
thanks :)

Connectez-vous pour commenter.

### Réponses (1)

Christopher Berry le 14 Août 2014
Jenny,
It seems like you just need to map your nodes to the input arguments for scatteredinterpolant. For an irregular grid of points, use the P,v inputs:
F = scatteredInterpolant(P,v)
where the rows of P contain the (x, y, z) coordinates for the values in v. You may have only 54 surface nodes, but your 3D volume actually has 54*20 = 1080 nodes, each with a temperature value v.
So, to construct P, you need to create a 1080x3 matrix. To do this first, turn all your variables into column vecotrs:
x = xnode(:);
y = ynode(:);
z = depthatnode(:);
v = tempatnode(:);
Now, you will need to replicate the x,y coordinates to match the number of values for z. To do this use repmat to generate repeating indexes for x and y
idx = repmat(1:54,20,1)
P = [x(idx(:)) y(idx(:)) z]
Now you should be able to generate your interpolant F using:
F = scatteredInterpolant(P,v)
There are a number of options for scatteredInterpolant, so take a look at the documentation to make sure F is being calculated the way you would like:
Now that you have a interpolant F, you can use it it to get estimated values anywhere inside your x,y,z range. One way to use this function is to create a regular grid using meshgrid, pass that set of points to t=F(gridpoints) and then work on the regular data, t;
I would create a regular grid like this:
xRange = linspace(min(x),max(x),10);
yRange = linspace(min(y),max(y),10);
zRange = linspace(min(z),max(z),20)
[X,Y,Z] = meshgrid(xRange,yRange,zRange)
But you can do it differently if you have specific z values you are interested in. Then find your estimated temperatures at these points:
t = F(X,Y,Z)
Hope that helps some.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Vector Volume Data 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