Interpolate to find values at particular points from a 45x28 matrix
Show older comments
Hi,
I currently have a 45x28 matrix [P] which is some pressures that I have measured experimentally over a single flat plane. The coordinates of the pressures in the x and y direction are [X,Y].
I have a two matrixes of x and y coordinates [x] and [y] respectively which I need to find the pressures for by interpolating from my pressure matrix as the exact x and y coordinates do not match my X and Y coordinates.
Can anyone please shed some light?
Thank you in advance.
Answers (2)
Matt Tearle
on 10 Feb 2012
Sounds like a job for TriScatteredInterp!
F = TriScatteredInterp(X,Y,P);
p = F(x,y);
Are X and Y matrices (same dimensions as P)? If not, you'll want some meshgrid action as well.
EDIT TO ADD: Sorry, I need to learn to read, sometimes. If you currently have data on a regular (coarse grid) and you want to move to a finer grid, use interp2. If you have scattered data, use TriScatteredInterp. Given that you did say your pressures are in a matrix P, it sounds like they're already on a regular X - Y grid. (So use interp2.)
p = interp2(X,Y,P,x,y);
surf(x,y,p)
EDIT TO ADD #2: Obviously I don't have your data files, but try this:
a = 0;
b = -0.39;
r = 0.2;
t = 0:step:(9*step);
ycirc = a + r*cos(t);
zcirc = b + r*sin(t);
[Ycirc,Zcirc]= meshgrid(ycirc,zcirc);
F = TriScatteredInterp(Y11(:),Z11(:),P11(:));
interp = F(Ycirc,Zcirc);
EDIT TO ADD #3(!): Do you actually want to meshgrid ycirc and zcirc? The end result is a rectangular grid with unequal spacing (but equal in polar coords). You can interpolate just onto a circle, if you want:
t = 0:step:(9*step);
ycirc = a + r*cos(t);
zcirc = b + r*sin(t);
F = TriScatteredInterp(Y11(:),Z11(:),P11(:));
interp = F(ycirc,zcirc);
surf(Y11,Z11,P11)
hold on
plot3(ycirc,zcirc,interp,'o')
Charlie
on 15 Feb 2012
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!