How to use scatteredInterpolant on given data?
Mostra commenti meno recenti
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 Commenti
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
il 8 Dic 2015
Adam
il 9 Dic 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
il 9 Dic 2015
What do you want done with the missing field on that first line?
arich82
il 9 Dic 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
il 9 Dic 2015
Modificato: Ibro Tutic
il 9 Dic 2015
Stephen23
il 26 Dic 2020
Rena Berman
il 6 Mag 2021
(Answers Dev) Restored edit
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Graphics Performance in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!