Documentation

interpft

1-D interpolation (FFT method)

Description

example

y= interpft(X,n)interpolates the Fourier transform of the function values inXto producen同样间隔的点。interpftoperates on the first dimension whose size does not equal 1.

example

y= interpft(X,n,dim)operates along dimensiondim。For example, ifX是矩阵,然后interpft(X,n,2)operates on the rows ofX

Examples

collapse all

使用FFT方法插值1-D数据并可视化结果。

Generate some sample points in the interval [ 0 , 3 π ] for the function f ( x ) = sin 2 ( x ) cos ( x ) 。使用间隔间隔dxto ensure the data is evenly spaced. Plot the sample points.

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

使用FFT插值在200个查询点找到功能值。

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

Calculate the spacing of the interpolated data from the spacing of the sample points withdy = dx*长度(x)/n, whereNis the number of interpolation points. Truncate the data inyto match the sampling density ofx2

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

Plot the results.

holdplot(x2,y,'.') title('FFT Interpolation of Periodic Function')

Generate three separate data sets of normally distributed random numbers. Assume the data is sampled at the positive integers,1:N。Store the data sets as rows in a matrix.

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

Interpolate the rows of the matrix at 500 query points each. Specifydim = 2so thatinterpftworks on the rows ofA

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

Calculate the spacing interval of the interpolated datady。Truncate the data inyto match the sampling density ofx2

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

Plot the results.

subplot(3,1,1) plot(x,A(1,:)','o'); holdplot(x2,y(1,:)','--') title('Row 1') subplot(3,1,2) plot(x,A(2,:)','o'); holdplot(x2,y(2,:)','--') title('Row 2')子图(3,1,3)图(x,a(3,:)',,,'o'); holdplot(x2,y(3,:)','--') title('Row 3')

Input Arguments

collapse all

Input array, specified as a vector, matrix, or multidimensional array. The data inX假定在自变量的间隔间隔间隔间隔间隔内进行采样。interpft最适合定期数据。

Data Types:single|double
Complex Number Support:Yes

Number of points, specified as a positive integer scalar.

Data Types:single|double

Dimension to operate along, specified as a positive integer scalar. If no value is specified, then the default is the first array dimension whose size does not equal 1.

  • interpft(X,n,1)插值X

  • interpft(X,n,2)插值行X

Example:interpft(X,n,3)

Output Arguments

collapse all

Interpolated points, returned as a vector, matrix, or multidimensional array. Iflength(X,dim) = m, andXhas a sampling interval ofdx,然后是新的抽样间隔yisdy = dx*m/n, wheren > m

Ifdimis specified, theninterpftpads or truncatesXto lengthnin dimensiondim, so thatsize(y,dim) = n

Algorithms

Theinterpftfunction uses the FFT method. The original vectorxis transformed to the Fourier domain usingFFT, and then it is transformed back with more points.

See Also

|

在R2006a之前引入