【问题标题】:MATLAB Data Interpolation - BasicsMATLAB 数据插值 - 基础
【发布时间】:2013-11-27 15:00:49
【问题描述】:

我有一个由位置和信号组成的数据集 - 信号在分散的位置(0、115、230...)进行采样:

0   1.709219858
115 1.676595745
230 1.643026005
345 1.609456265
460 1.574940898
575 1.540898345
690 1.506855792
806 1.473286052

我想平滑这些数据,然后对其进行插值以填充中间位置,即:

0   x
1   x
2   x
3   x
4   x
5   x
6   x
7   x
8   x
9   x
10  x

其中 x 是平滑后的信号。我一直在使用以下命令平滑数据:

>> hann250=hanning(250); 

>> smooth250=conv(signal,hann250,'same');

但我完全不确定如何插入数据 - 我可以使用哪些命令以及输入什么?我对 MATLAB 完全陌生!我也不确定我需要什么插值方法,但我打算尝试各种方法看看(一旦我知道怎么做!)。谢谢,

T

【问题讨论】:

  • 检查interp1。要查看其文档,请在 Matlab 中输入 help interp1

标签: matlab interpolation


【解决方案1】:

您可以尝试样条插值:

http://www.mathworks.com/help/matlab/ref/spline.html

% read x, y from your file
xx = linspace(min(x), max(x), 1000); % generate 1000 equally spaced points
yy = spline(x,y,xx); % interpolate
plot(x,y); % original
hold all;
plot(xx,yy); % new

【讨论】:

  • 太棒了!非常感谢。
【解决方案2】:

你可以使用interp1:

data = [0    1.7092
 115.0000    1.6766
 230.0000    1.6430
 345.0000    1.6095
 460.0000    1.5749
 575.0000    1.5409
 690.0000    1.5069
 806.0000    1.4733];

index_interp = 0:806; %// indices on which to interpolate
data_interp = interp1(data(:,1),data(:,2),index_interp,'linear');

除了'linear',还有其他的插值方法;见上面的链接。

【讨论】:

  • 谢谢,这真的很有帮助!
猜你喜欢
  • 2013-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-12
  • 2017-04-02
  • 1970-01-01
  • 1970-01-01
  • 2016-12-08
相关资源
最近更新 更多