Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

interpft

一维插值(FFT 方法)

说明

示例

y = interpft(X,n)X 中内插函数值的傅里叶变换以生成 n 个等间距的点。interpft 对第一个大小不等于 1 的维度进行运算。

示例

y = interpft(X,n,dim) 沿维度 dim 运算。例如,如果 X 是矩阵,interpft(X,n,2) 将在 X 行上进行运算。

示例

全部折叠

使用 FFT 方法对一维数据插值,并以可视方式呈现结果。

在区间 [0,3π] 内为函数 f(x)=sin2(x)cos(x) 生成一些样本点。使用间距 dx 以确保数据等间距。绘制样本点。

dx = 3*pi/30;
x = 0:dx:3*pi;
f = sin(x).^2 .* cos(x);
plot(x,f,'o')

Figure contains an axes object. The axes contains a line object which displays its values using only markers.

使用 FFT 插值,以查找 200 个查询点处的函数值。

N = 200;
y = interpft(f,N);

使用 dy = dx*length(x)/N 基于样本点的间距计算插值数据的间距,其中 N 是插值点的数目。截断 y 中的数据以匹配 x2 的采样密度。

dy = dx*length(x)/N;
x2 = 0:dy:3*pi;
y = y(1:length(x2));

绘制结果。

hold on
plot(x2,y,'.')
title('FFT Interpolation of Periodic Function')

Figure contains an axes object. The axes object with title FFT Interpolation of Periodic Function contains 2 objects of type line. One or more of the lines displays its values using only markers

生成由正态分布的随机数组成的三个单独的数据集。假定在正整数 1:N 这些点处进行数据采样。将数据集存储为矩阵中的行。

A = randn(3,20);
x = 1:20;

对每 500 个查询点的矩阵行插值。指定 dim = 2 以便 interpftA 的行进行插值。

N = 500;
y = interpft(A,N,2);

计算插值数据点之间的间距 dy。截断 y 中的数据以匹配 x2 的采样密度。

dy = length(x)/N;
x2 = 1:dy:20;
y = y(:,1:length(x2));

绘制结果。

subplot(3,1,1)
plot(x,A(1,:)','o');
hold on
plot(x2,y(1,:)','--')
title('Row 1')

subplot(3,1,2)
plot(x,A(2,:)','o');
hold on
plot(x2,y(2,:)','--')
title('Row 2')

subplot(3,1,3)
plot(x,A(3,:)','o');
hold on
plot(x2,y(3,:)','--')
title('Row 3')

Figure contains 3 axes objects. Axes object 1 with title Row 1 contains 2 objects of type line. One or more of the lines displays its values using only markers Axes object 2 with title Row 2 contains 2 objects of type line. One or more of the lines displays its values using only markers Axes object 3 with title Row 3 contains 2 objects of type line. One or more of the lines displays its values using only markers

输入参数

全部折叠

输入数组,指定为向量、矩阵或多维数组。X 中的数据假定为按自变量的等间距间隔进行采样。interpft 最适合周期性数据。

数据类型: single | double
复数支持:

点数,指定为正整数标量。

数据类型: single | double

沿其运算的维度,指定为正整数标量。如果未指定值,则默认值是大小不等于 1 的第一个数组维度。

  • interpft(X,n,1)X 的列进行插值。

    interpft(X,n,1) column-wise computation

  • interpft(X,n,2)X 的行进行插值。

    interpft(X,n,2) row-wise computation

示例: interpft(X,n,3)

输出参数

全部折叠

插入的点,以向量、矩阵或多维数组形式返回。如果 length(X,dim) = m 并且 X 的采样间隔为 dx,则 y 的新采样间隔将为 dy = dx*m/n,其中 n > m

如果指定 dim,则 interpft 会填充或截断 X,使其长度等于维度 dim 中的 n,以便 size(y,dim) = n

算法

interpft 函数使用 FFT 方法。使用 fft 将原始向量 x 变换为傅里叶域,然后通过更多的点变换回原始向量。

扩展功能

版本历史记录

在 R2006a 之前推出

另请参阅

|