matlab taylorwin(L,nbar,sll) C/C++实现
时间: 2024-05-22 07:15:24 浏览: 139
计算机控制状态空间反馈课程设计.doc
以下是 Matlab 的 taylorwin(L,nbar,sll) 函数的实现:
function w = taylorwin(L, nbar, sll)
% TAYLORWIN Generate a Taylor window
%
% w = TAYLORWIN(L, nbar, sll) generates an L-point Taylor window
% with sidelobe level attenuation in dB specified by sll and a
% parameter nbar.
%
% Reference: Harris, F.J. "On the Use of Windows for Harmonic
% Analysis with the Discrete Fourier Transform," IEEE Proc., Vol.
% 66, No. 1, January 1978, pp. 51-83.
%
% Example:
% L = 64;
% nbar = 8;
% sll = 40;
% w = taylorwin(L, nbar, sll);
% plot(w);
% title('64-Point Taylor Window, nbar = 8, SLL = 40 dB');
%
% See also BLACKMAN, BLACKMANHARRIS, HAMMING, HANN, KAISER, NUTTALLWIN,
% RECTWIN, TRIANG, TUKEYWIN.
% Check inputs
narginchk(3, 3);
validateattributes(L, {'numeric'}, {'scalar', 'integer', 'positive'});
validateattributes(nbar, {'numeric'}, {'scalar', 'integer', 'positive'});
validateattributes(sll, {'numeric'}, {'scalar', 'nonnegative'});
% Compute alpha
alpha = (sll + 13) / 22;
% Compute beta
beta = alpha * sqrt(1 - (2*(0:(L-1))/(L-1) - 1).^2);
% Compute the Taylor window
w = zeros(1, L);
for n = 0:(L-1)
w(n+1) = besseli(0, nbar*beta(n+1))/besseli(0, nbar*alpha);
end
end
该函数首先检查输入参数(L,nbar,sll)是否符合要求,然后计算 alpha 和 beta 值,最后根据 beta 和 nbar 计算 Taylor 窗口。计算 Taylor 窗口时使用了贝塞尔函数 besseli。
阅读全文