MATLAB Answers

## Interpolating Values Along Line

Asked by Michael

### Michael (view profile)

on 1 May 2013

I currently have 3 different matrices, 1 for x-coordinate of points, 1 for y-coordinate of points, and 1 for pressure at the point. I want to interpolate the value of pressure along a line in between the some of the current coordinates. I am not sure how to go about this. Any help would be much appreciated!

## Products

No products are associated with this question.

## 2 Answers

### Walter Roberson (view profile)

Answer by Walter Roberson

### Walter Roberson (view profile)

on 2 May 2013

http://www.mathworks.com/help/matlab/ref/interp2.html

ZI = interp2(X,Y,Z,XI,YI)

So in your case

InterpolatedPressure = interp2(X, Y, Pressures, NewX, NewY);

### Youssef Khmou (view profile)

Answer by Youssef Khmou

### Youssef Khmou (view profile)

on 2 May 2013
Edited by Youssef Khmou

### Youssef Khmou (view profile)

on 2 May 2013

hi,

you mean interpolating the matrix P of pressure to increase the samples, or to find the coordinates where certain values of Pressure occur?

1)for the first :

You define your new X2,Y2 coordinates ( matrices , using meshgrid as example) :

P_new=interp2(X,Y,P,X2,Y2); % the new matrix P_new is interpolated

2) for the second :

Suppose that the matrix P contains a value 100 N/m², we want to find the coordinates where that value occurs :

D=P-100.00;
tolerance=1e-3;
[indx1,indx2]=find(abs(D)<tolerence);

Walter Roberson

on 2 May 2013
Youssef Khmou

### Youssef Khmou (view profile)

on 2 May 2013

ok thanks !

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

### MATLAB Academy

New to MATLAB?

Learn MATLAB today!