How to use scatteredInterpolant on given data?
Show older comments
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
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.
Ibro Tutic
on 8 Dec 2015
Adam
on 9 Dec 2015
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.
Walter Roberson
on 9 Dec 2015
What do you want done with the missing field on that first line?
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
on 9 Dec 2015
Edited: Ibro Tutic
on 9 Dec 2015
Stephen23
on 26 Dec 2020
Rena Berman
on 6 May 2021
(Answers Dev) Restored edit
Accepted Answer
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!