interpolation

8 views (last 30 days)
Rotem
Rotem on 1 Apr 2012
hello I have two sets of data one is natural and the other is from experiment, the first is bigger than the second and more dense each data type have (t,x,y) how can I interpolate the data from the experiment using all of data vectors (t,x,y)? I want to calculate the error between the two thanks By the way i tried interp with no success I think I need to use amshgrid but I dont know ho to use it

Answers (3)

Aaditya Kalsi
Aaditya Kalsi on 1 Apr 2012
This is an easy one.
Let's say you have non-uniformly sampled data t, x, y. You want to find uniformly distributed values for these now.
I am assuming that t = f(x, y).
First we can define the the uniform grid we want the answers on. This usually would be like:
x = rand(100, 1);
y = rand(100, 1);
t = (x + y).^2;
% spacing
divUnit = 0.01;
xUnif = min(x) : divUnit : max(x);
yUnif = min(y) : divUnit : max(y);
% obtain the regural grid by MESHGRIDing the regularly spaced vectors
[X, Y] = meshgrid(xUnif, yUnif);
% interpolate 't' on this uniform grid
intObj = TriScatteredInterp(x, y, t);
T = intObj(X, Y);
% plot what we have
figure;
scatter3(x, y, t);
hold on;
surf(X, Y, T);

Aaditya Kalsi
Aaditya Kalsi on 1 Apr 2012
If you want to find the error between the two, you might be better of finding a model to predict this 'data' and then use Statistics to figure out how confidently your model fits each dataset. That would be the best way. The interpolation above may not be what you're looking for. For information on what Interpolation is performed here try:

Rotem
Rotem on 3 Apr 2012
Hey thanks for the quick respond Your second answer is more or less what I tried to do by using polyfit I wanted to create function, take out the coefficients using polyval and from there to enter the other set of data to calculate the error between them
There things thought that I may not explain correctly
1. I have two sets of data
2. each data have 4 kind of variables t,x,y,z (for start I am using only 3)
3. the two data sets are not monotonically except (t)
4. they are not in the same length though I can pad them with zeroes (still need to find the function that do that or create one myself)
5. both of the data are not uniformly distributed the distance between measurements are

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!