interpolation

1 次查看(过去 30 天)
Rotem
Rotem 2012-4-1
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

回答(3 个)

Aaditya Kalsi
Aaditya Kalsi 2012-4-1
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 2012-4-1
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 2012-4-3
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

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by