Create rectangular mesh from non-rectangular mesh and interpolate

9 views (last 30 days)
Hey Everyone
I have a non-rectangular grid in 3D space in which each point in 3D space is assigned a value (Basically a CFD mesh). I would like to transport this to a rectangular mesh because using MATLAB's 'slices' would be very beneficial to visualize the flow. To visualized this I basically have a pyramid to start with, and need to mesh it into a rectangle that encompasses it all.
My 3D data is broken into X,Y,Z, and MAG. The nature of these are what you'd expect, each a 3D array and they are formatted properly, I've checked them all. What I'd like to do is interpolate the MAG data into a mesh grid that goes from min(X)-max(X) and same for Y and Z. Here is what I have so far.
[Xm,Ym,Zm]=meshgrid(min(X(:):1:max(X(:)),min(Y(:)):1:max(Y(:)),min(Z(:)):1:max(Z(:)));
NEWMAG=interp3(X,Y,Z,MAG,Xm,Ym,Zm);
Unfortunately I cannot even get past this because I get an error stating this is an invalid mesh for the use of interp3 and I cant figure out why.
Any help would be great.
Thanks

Accepted Answer

kschau
kschau on 11 Jun 2013
I figured out the best way for anyone who needs to do something similar. using 'slice' is out of the question, the remapping and interpolating just takes WAY too much computing time.
Instead, it was very quick and efficient to just recreate ONLY the slices I wanted to display via for loops, then use the 'surf' or 'scatter3' to display these. Even though they were 2D slices, they were still represented by T=f(x,y,z) coordinates in 3D space, so that's how I went about it and it did exactly what I needed it to.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!