How to use scatteredInterpolant on given data?

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.

8 Comments

Adam
Adam on 8 Dec 2015
Edited: Adam on 8 Dec 2015
v in the ScatteredInterpolant is just your data values at the x and y locations.
It is just presented as being v = F(x,y) because effectively that is what it is. You don't have to actually have the function, F, just the points that correspond to the x and y data points given.
Would there be a simple way of going about this using the file that I uploaded? I guess I am wondering how would I go about interpolating so many points.
I didn't look at the specific data, but first thing you'd need to do is load it into Matlab rather than in a csv file, but if you have a number of data points equal to your number of x and y points (or whatever 2 dimensions you have for 'position') then it should work fine. I don't know about its performance with respect to size of inputs though.
What do you want done with the missing field on that first line?
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?
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!
(Answers Dev) Restored edit

Sign in to comment.

 Accepted Answer

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

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!
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).
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)

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!