Interpolation between 2 data sets acquired at same grids

Hi,
I have two data sets, that are sampled at same height (y axis) (see image) and I would like to obtain the data set in between by interpolation. I tried interp1 but it is not working for me. I used to do interplation to obtain points at different height in the same profile, but when I try to interpolate to abtain the data points in between 2 different profiles at the same heights, it is not working. Any help would be appreciated.

2 Comments

Did you try to interpolate in X direction (horizontally)?
Please provide your code
U_3_I = interp1(Height, profile,newHeight);
I used to use this code to obtain the data point at different height in the profile.
I tried using this,
U_3_I = interp1(profile1, profile2,Height);
but this does not work. Can you explain how to interpolate in X direction?

Sign in to comment.

 Accepted Answer

"when I try to interpolate to abtain the data points in between 2 different profiles at the same heights, it is not working"
If both data sets share the same Y value, then the result of interpolation is just going to be the average of their X values. No need to use interp for this. Just use mean.

9 Comments

I want to obtain multiple profiles in between the 2. I just want to know how I could use interpolation to obtain the mean as you mentioned. Thank you!
I think about it this way. Interp1 will add additional points to your line (in between the existing points). This is what darova means by interpolating along X. You would create "lines" between the x values at each hight, and interpolate each height separately. But interp1 doesn't work when all your Y values are the same. The interpolated value could be any X value.
The way interp1 works is to take known X and Y values, and then specify a query X value, and interpolate to find the corresponding Y value. X and Y are arbitrary. Basically, you use the known to interpolate the unknown.
You know Y and want to interpolate X. But there is nothing "identifying" about Y to let you interpolate to a specific X.
That's true. Thank you so much
Hi again,
Actually, I tried to take the average of X of both profiles. However it did not match what interpolation gave me. The way I interpolated this by considering the horizontal distance between both profile. So let's say x1 data were taken at 0 meter in in horizontal direction and x2 data were taken at 25 meter in horizontal direction, and I want the profile at 12.5 meter in horizontal.
my code is as follow:
% x1=Profile1 data;
% y1=location of x1 in horizontal direction;
% x2=Profile2 data;
% y2=location of x2 in horizontal direction;
% y=location of desired x in horizontal direction;
% x=(((y-y1)/(y2-y1))*(x2-x1))+x1;
There was a slight variation between what the average of both profiles would give, and the interpolation in horizontal direction would give. Which one is more accurate. Thanks
Can you provide actual numbers? Better, share your data. You can save it to a mat file and attach that to your post using the paperclip icon.
Sure, I have included the data to the main post
Your data is 2 horizontal lines, not the 2 vertical lines you show in the OP. Here, the X values are different in each line. In the orignal plot, the Y values were the same. When they are the same, averaging gives the same result as interpolation. When they are not, and therefore the line between the point is not horizontal or vertical, then ageraging and interpolation will yield different answers, the difference being very dependent on how much slope is in the line.
In this case I would use interpolation between the corresponding points between the lines (so do it 20 times).
Actually, what you mentioned at the begining about averaging is correct. my two data set have the same y value, and thus, interpolation gives the same answer as averaging. I think I have made a mistake somewhere which casued the answer to be different.
Thank you so much for youe help

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!