MATLAB Answers

How to use scatteredInterpolant on given data?

191 views (last 30 days)
Hi all.
I am not quite sure on how to use scatteredInterpolant. I tried reading up on it, but it doesn't make sense to me since I don't have a function v. All I have are points that I need plotted/interpolated. I attached a csv document with some sample data (not actual values, just place holders). Thanks for any help.

  6 Comments

Show 3 older comments
Walter Roberson
Walter Roberson on 9 Dec 2015
What do you want done with the missing field on that first line?
arich82
arich82 on 9 Dec 2015
Given that there is indeed a missing field in the first entry, I wonder if this is truly 11-D data, or if it's just a table of 2-D data, where the first column and row are the independent variables:
A = csvread('Edited..csv');
x = A(2:end, 1);
y = A(1, 2:end);
data = A(2:end, 2:end);
It seems like the data is really just F(x, y) = 5 (I realize 5 is just dummy data for the example), where x = [100:-5:5, 2] and y = [2200:-22:1200, 1100:-100:800].
If that's the case, the data is already set up to use griddedInterpolant, though scatteredInterpolant should work equally as well if it's only 2-D.
[X, Y] = ndgrid(x, y);
F_scattered = scatteredInterpolant([X(:), Y(:)], data(:));
F_gridded = griddedInterpolant({flipud(x), fliplr(y)}, flipud(fliplr(data)))
(Note that gridded gets a little ugly since the grid vectors are monotonic decreasing instead of increasing, hence the flipud and fliplr.)
You could then interpolate using e.g. F_scattered(97.5, 2190.8).
Am I misinterpretting the attached file?
Ibro Tutic
Ibro Tutic on 9 Dec 2015
Nope, you understood the way I had hoped. Thanks! I think I was getting near your solution, but I kept getting confused with the gridded interpolate. I got everything figured out, thanks!

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Dec 2015
You appear to be wanting to do an 11-dimensional scattered interpolation. Unfortunately MATLAB does not have any scattered interpolation routines that work in more than 3 dimensions, but gridded interpolation can. In a previous discussion Kelly provided a means to convert a scattered vector to gridded information, but it can potentially take up a lot of memory.
On the other hand, you indicate that you want to be able to plot this. There is no way you will be able to plot in 11 dimensions: there are not enough graphics attributes available for more than about 7 dimensions (not saying the plot would be easy to read for that many dimensions...)

  3 Comments

Ibro Tutic
Ibro Tutic on 9 Dec 2015
Yea, I didn't really mean to say I wanted to plot it, was just trying to get my thoughts out I guess. But I will look into the gridded interpolation. Thanks!
Ibro Tutic
Ibro Tutic on 9 Dec 2015
Are you sure that this would be 11 dimensional? If you look at the breakpoints in the 1st column and assume these to be x coordinates, and the breakpoints in the 1st row and assume these to be y coordinates, wouldn't it be possible to graph the stuff mapped to these values on the z axis? Making this 3d, where scatteredinterpolant would work. (F(x,y)=z type relationship).
Walter Roberson
Walter Roberson on 10 Dec 2015
Ummm, it is your data file, and you said the points were in the file, without specifying rows or columns...

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by