📄 fourier_fit.m
字号:
function [y,ty]=fourier_fit(x,tx,Ny)
% [y,ty]=fourier_fit(x,tx,Ny)
%
% Frequency-limited fit (y) to data (x) not uniformly
% spaced in time (tx).
% Inputs:
% x =vector of data samples.
% tx =vector of corresponding time samples.
% Ny =number of samples in (length of) output y.
% Output:
% y =Ny samples of the inverse DFT of x.
% ty =vector of time samples corresponding with y.
% Note: The period of y is taken to be max(tx)-min(tx).
% Error checks etc.
if length(tx)~=length(x)
error('In fourier_fit, tx and x must have the same length.');
elseif Ny<3
error('In fourier_fit, Ny must be >2.');
elseif max(tx)-min(tx)<=0
error('In fourier_fit, max(tx)-min(tx) must be >0.');
end
Nx=length(x); % Nx= # input samples
P=max(tx)-min(tx); % fundamental period of series
ty=linspace(min(tx),max(tx),Ny); % time vector for output y
Ny2=floor(Ny/2); % half of Ny or Ny-1
mt=col_vec(tx)*[0:Ny2]; % array of exponents
w=exp(j*2*pi*mt/P); % exponential factor in transform
X=row_vec(x)*w ; % half of the DFT components
X=[X rev(conj(X(2:Ny2)))] % all Ny components of the DFT
y=real(ifft(X)); % y with Ny-1 samples
y=[y y(1)]; % y with Ny samples
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -