Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MATLAB velocity vector interpolation

759 views
Skip to first unread message

Megan Yocom

unread,
Nov 18, 2009, 11:26:19 AM11/18/09
to
I have a set of data, y,z points, each point containing an x,y,z velocity vector. These points are nonuniform. I am interested in interpolating between points to create a uniform matrix. I'm not sure which interpolation method would be the best choice.

For instance, if I consider the center of my flow field to be the origin, and I am interested in every 15' point from the center, every 5 degrees around the origin point, how would I interpolate the velocity vector that would be at this point, knowing the velocities around that point?

Sujeet Phanse

unread,
Nov 18, 2009, 1:25:16 PM11/18/09
to
This might be what you are looking for:

http://www.mathworks.com/access/helpdesk/help/techdoc/math/brzxg0k.html


"Megan Yocom" <megan...@cox.net> wrote in message
news:he177b$8i6$1...@fred.mathworks.com...

Megan Yocom

unread,
Nov 19, 2009, 8:59:20 AM11/19/09
to
If I don't have this function "TriScatteredInterp" would there be another method that would work? Is this function contained in a particular toolbox?

"Sujeet Phanse" <sph...@mathworks.com> wrote in message <he1e6e$oi3$1...@fred.mathworks.com>...

Raphael Attie

unread,
Nov 19, 2009, 1:30:22 PM11/19/09
to
Hi,

I'm working also on similar stuff, with velocity vector. I started using this routine recently, it seems to work for Non-uniform>uniform grid. It is not in a particular toolbox. It should be natively in Matlab. Which version of Matlab do you have ?

"Megan Yocom" <megan...@cox.net> wrote in message <he3ivo$i8c$1...@fred.mathworks.com>...

Megan Yocom

unread,
Nov 19, 2009, 4:53:17 PM11/19/09
to
I realized this is in 2009. I was able to find a workstation with this version of MATLAB, so I will have this function. I'm still unsure that this is what I'm looking for.

The velocity vectors I am dealing with contain an x,y,z direction (i,j,k) and a position of y,z. For

F = TriScatteredInterp(X, Y, V)

X and Y are my position vectors Y and Z? How do I define what interpolated points I am interested in, then? For V, can I input that as an i,j,k vector? Or do I first need to find the magnitude of the resultant vector? It isn't clear to me what F will output. If V is a 3x column vector, will F output as a 3x column vector stating the interpolated i,j,k components of the point I am interested in? Where does F determine interpolated values if X and Y are my position vectors that I already have?

Thank you so much for your help and input. I really appreciate it

"Raphael Attie" <at...@mps.mpg.de> wrote in message <he42ru$sp$1...@fred.mathworks.com>...

Raphael Attie

unread,
Nov 19, 2009, 8:32:17 PM11/19/09
to
Hi Megan,

So, let's tidy up a bit all this =)

First of all, i'm not sure I understand what you meant by :
"The velocity vectors contain an x,y,z direction (i,j,k) and a position of y,z."
Do you mean your position is a function of (y,z) ? What do you mean by "position" ?

As for the rest, it is now very important to understand that you are dealing with vector fields, and not scalar fields. Dealing with the magnitude won't help give you back each component. Your vector field must be dealt component by component I assume, as each Vx, Vy, and Vz would be considered as scalar field, function of 3D coordinates (Vx(i,j,k), Vy(i,j,k), Vz(i,j,k)).

The approach I take with this is that the uniformly gridded 3D velocity vector will be obtained once each of them has been uniformly gridded through the call to the routine. So, it means, if you can do for one, you can do for all three, and you'll be all set (or almost =)

If I understand correctly, you have Vx, Vy, and Vz, in a variable, say , V=[Vx,Vy,Vz].
However, how are things dimensionned ? Are Vx, Vy, Vz all 3D arrays ?
Or are each of them dimensioned as row or column vectors ? (their 1D conversion from an initial 3D array, like when you do V1D=V3D(:) )

Do you have some other arrays, or vectors, that contain the coordinate of each data point in your velocity vectors ?

If you could simply copy paste the results of the command "size" on your main variables, that would clear things up a lot.

See you,

Raphael

"Megan Yocom" <megan...@cox.net> wrote in message <he4eod$l3l$1...@fred.mathworks.com>...

Raphael Attie

unread,
Nov 19, 2009, 8:42:19 PM11/19/09
to
One last thing is worth mentionning :

If you're interested in the magnitude of the velocity vector, then you should work on that from the begining, as it will be a true scalar field.
Interpolation of vector field can be an issue when interpolating component by component if you're only interested in the magnitude, because the magnitude of the interpolated field will not be strictly equal to the interpolated magnitude. This come from the definition of algebraic definition of the magnitude. The magnitude is defined in a vectorial set. Changing the set, is also changing the definition magnitude in this new set. (I might have a few reference here and there if you do need that, i just hope they are in english (i'm french)).

So, keep me posted when you make some progress, or if you get stuck =)

Raphael

"Raphael Attie" <at...@mps.mpg.de> wrote in message <he4rj1$cut$1...@fred.mathworks.com>...

Megan Yocom

unread,
Nov 20, 2009, 12:07:20 PM11/20/09
to
This if for a flow field, so what I mean is that I have a scattered list of data points that define position (around a propeller). Each of these points has a flow (wind) direction in the x, y, a z directions. I hope that explains a little better what I'm looking at.

The ultimate goal would be to make this data "uniform" by specifying points (or locations) that are every "a" distance away from the origin, finding the points around that area that we actually know, then use what we know about the wind components in all directions to find what they could be for that point, then eventually exporting this data for our CFD model. Our CFD program needs uniform data in order to do it's own analysis, my job is to create this uniform data.

I hope this clears up what I'm working with. A small subset of data that I have is:
Y (m) Z (m) x velocity (m/s) y velocity (m/s) z velocity (m/s)
5.02 3.80 120.68 -13.40 -70.40
6.60 1.29 113.06 -48.58 51.64
5.57 3.74 83.52 -20.01 -56.39
3.48 1.63 93.65 50.00 -2.56
3.64 2.93 119.31 40.65 -55.42
6.59 2.92 115.36 -64.98 -18.45
6.73 2.62 84.93 -62.37 -16.68
6.74 2.57 86.13 -61.28 -17.30
4.68 0.46 70.21 -6.71 37.04

So the Y and Z are the position that I know. The corresponding x,y,z are the wind compoenents for that point.

I'm looking at doing a Delaunay triangulation of all of the data. This will just create all of the triangles that make up this scattered data if I understand correctly. Then I can create a vector of specified number of points every 0.5m (for instance) from the origin. wherever this point lies it may be possible to find the triangle it lies within. Knowing the tirangle, I could find the vertices around the point, using this information I can index into my velocity components to find what velocity compoents coorespond to these vertices. Then, I would need to interpolate the velocity component at my "unknown" point.

The greatest issues here are
a: I don't know how to find what triangle my uniform point values would lie within.
b: I don't know how to interpolate the known wind compoenents (with their known positions) to find the unknown components at this point. This would depend on distance away from the known vertices.

Does this better explain my dilema?

I can't thank you enough for your help. This is just something I haven't attempted before, but I'm pretty confident it could be possible...

"Raphael Attie" <at...@mps.mpg.de> wrote in message <he4s5r$ia1$1...@fred.mathworks.com>...

Damian Sheehy

unread,
Nov 20, 2009, 2:42:13 PM11/20/09
to
Hi Megan,

I believe TriScatteredInterp will solve your problem. You do not
need to work with DelaunayTri directly. Raphael's use-case is not quite the
same as yours. If you described your propeller analysis example in your
initial post you may have gotten more useful replies. In the absence of that
posters had to guess what you were trying to do.


You have a set of scattered data at x, y locations and at each location you
have 3 separate values (velocity components).
The trick is to make 3 separate passes (evaluations) thereby interpolating
each velocity component separately.
Here's a quick sketch. . .

Let's say your scattered data is defined at locations x, y, and you have 3
velocity components (v1, v2, v3) defined at each location. You wish to query
the interpolant at "uniform" locations xi, and yi. What you are looking for
is the corresponding velocity components, v1i, v2i, and v3i. You got stuck
because you tried to do everything in one shot. The key to do it in 3 steps.

Step 1) Create the interpolant that models the first velocity component
F = TriScatteredInterp(x,y, V1)

% Now use it to evaluate the interpolant at the uniform locations (xi,
yi) this will give us v1i
v1i = F(xi,yi);

Step 2) Modify the interpolant so that we can now use it to interpolate the
second velocity componnet

F.V = v2

% Now use it to evaluate the interpolant at the uniform locations (xi,
yi) this will give us v2i
v2i = F(xi,yi);


Step 2) Modify the interpolant so that we can now use it to interpolate the
third velocity componnet

F.V = v3

% Now use it to evaluate the interpolant at the uniform locations (xi,
yi) this will give us v3i
v3i = F(xi,yi);


You now have all the data that you need to feed to the CFD program. There's
only one thing remaining. How to generate the uniform data? You mentioned
that you wanted a radial grid that has 5 degree sample size.

% Create the parameters
t = (0:pi/36:2*pi)';
% Remove the last point as it's a duplicate
t(end) = [];

% Now evaluate the xi yi values at some radius R
R = 1.0
xi = R*cos(t);
yi = R*sin(t);

You can expand xi and yi by evaluating at various values of R.

Users in the area of image analysis routinely perform interpolations like
this. Images can be made up of 3 separate colors (Red, Green, Blue) so to
interpolate an image they make three separate passes. First interpolating
the Red value, then the Green, followed by the Blue.

I think this should get you up and running. . .


Best regards,


Damian

"Megan Yocom" <megan...@cox.net> wrote in message

news:he6ic8$q3g$1...@fred.mathworks.com...

Raphael Attie

unread,
Nov 20, 2009, 4:34:21 PM11/20/09
to
Hi Megan, (hi again Damian ;)

So, if I understand correctly (please correct me if i'm wrong), your (Y,Z) coordinates is a 2D plane in which your Vx, Vy, Vz are defined, isn't it ? This is indeed what i think didn't get quite right at first, as I thought the Vx, Vy, and Vz were defined in a 3D box and not on a 2D plane. And I assume this plane would be defined by (y,z) coordinates, and that Damian referred as (x,y) coordinates, am i still correct guys ?

I'll give the lead to Damian, he helped me out previously with my own case too, and i can again learn again from this example too.

Raphael

Megan Yocom

unread,
Dec 2, 2009, 9:21:19 AM12/2/09
to
I have done exactly what you described below, and for the first velocity it works fine. When I do the second step;
F.V=v2
v2i=F(xi,yi)
I get the following error:
??? Error using ==> subsref
The interpolant is in an invalid state.
The number of data point locations should equal the number of data point values.
I don't know what this error means.
xi and yi are both 16x1 doubles
F is the TriScatteredInterp from x,y,v1; which are all of size 62088x1.

I've even tried to do the TriScatteredInterp for v2, i.e.
F=TriScatteredInterp(x,y,v2)
then
v2i=F(xi,yi)
and I get the same error. This is exactly what I do for v1, and it works (or at least seems to work) fine. What am I doing wrong???

Thanks!


"Damian Sheehy" <Damian...@mathworks.com> wrote in message <he6reo$htp$1...@fred.mathworks.com>...

0 new messages