How can I interpolate 3 columns of data independently of each other?

9 visualizzazioni (ultimi 30 giorni)
I am using MATLAB R2010b and have an Excel file consisting of three columns with data that I wish to interpolate between each point in the column. I only want to interpolate values within one column, not between each column. I initially tried using interp2 function to do this, which worked except it interpolated between columns. Below is the script I have used unsuccessfully so far. The Excel file that it is pulling from is titled "interpolateexcel.xlsx".
format long g
filename = 'interpolateexcel.xlsx';
c = xlsread(filename,'A2:A139');
d = xlsread(filename,'B2:B139');
e = xlsread(filename,'C2:C139');
c1 = c;
d1 = d;
e1 = e; V = [c1,d1,e1];
VI = interp2(V,1);
I have also attempted to use "griddedInterpolant" on this data, but I do not believe my current version of MATLAB has this feature.
  1 Commento
Image Analyst
Image Analyst il 3 Feb 2015
Instead of the 1,2,3,4,5,... spacing that you get right after reading from Excel, what do you want as the spacing for values? Like 1, 1.1, 1.2, 1.3,..... or something?

Accedi per commentare.

Risposte (2)

dpb
dpb il 3 Feb 2015
doc interp1
  1 Commento
Trevor Brown
Trevor Brown il 3 Feb 2015
When I use interp1 in the following way, I do not get a correct interpolation of the data.
VI = interp1(c1,V);
Primarily, I get "NaN" instead of the numerical values, and the numerical values I receive are incorrect. What am I missing here? For reference, I have attached the Excel file used in the code.

Accedi per commentare.


dpb
dpb il 3 Feb 2015
From
help interp1
...
Vq = interp1(V,Xq) assumes X = 1:N, where N is LENGTH(V)
for vector V or SIZE(V,1) for array V.
You've told interp1 to use 1:length(V) or [1:138] ax Xi, the vector of interpolants. This is all outside the range of
>> min(xyz(:,1))
ans =
672
>> max(xyz(:,1))
ans =
6400
so NaN is what you should expect unless you use the 'extrap' optional parameter.
But, given that your data are apparently an xyz grid, linear interpolation along the columns as you've described makes no sense, anyway.
What are you trying to get?

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by