Interpolate to find values at particular points from a 45x28 matrix
이전 댓글 표시
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.
답변 (2개)
Matt Tearle
2012년 2월 10일
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')
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!