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

9 次查看(过去 30 天)
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 个评论
Image Analyst
Image Analyst 2015-2-3
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?

请先登录,再进行评论。

回答(2 个)

dpb
dpb 2015-2-3
  1 个评论
Trevor Brown
Trevor Brown 2015-2-3
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.

请先登录,再进行评论。


dpb
dpb 2015-2-3
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?

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by