matlab taylorwin(n,nbar,sll)函数 c/c++代码实现
时间: 2024-05-27 22:12:28 浏览: 17
function w = taylorwin(n, nbar, sll)
% TAYLORWIN - Compute a Taylor window
%
% w = taylorwin(n, nbar, sll) returns an n-point Taylor window with a
% sidelobe level of sll dB and a mainlobe width of nbar points. The
% coefficients are computed using an iterative algorithm based on the
% Taylor series expansion. The window is symmetric and centered around the
% midpoint.
%
% Author: Ivan Selesnick
% Revised: 15 Dec 2015
%
% Reference: J. F. Kaiser, "Nonrecursive digital filter design using I_0-sinh
% window function," Proc. IEEE International Symposium on Circuits and Systems,
% pp. 20-23, April 1974.
%
% Example:
% n = 64; nbar = 6; sll = 40;
% w = taylorwin(n, nbar, sll);
% figure; plot(w); grid
% title(['Taylor window (', num2str(n), ', ', num2str(nbar), ', ', num2str(sll), ')'])
%
% Note: For nbar = 4 and sll = 60, this is a Kaiser window.
if nargin < 3, sll = 30; end
if nargin < 2, nbar = ceil(n/2); end
% Algorithm parameters
delta = 10^(-sll/20); % Desired sidelobe suppression
M = floor((n-1)/2); % Window margin
alpha = nbar/M; % Scaling factor
a0 = 2*M+1; % Initial value of a
max_iter = 100; % Maximum number of iterations
% Initialize coefficients
a = a0;
w = zeros(n,1);
w(n/2+1) = 1;
for k = 1:M
% Compute coefficients using Taylor series expansion
sum_ak = a;
term = a;
for iter = 1:max_iter
term = -(term*(k^2)/(sum_ak*(a+iter)));
sum_ak = sum_ak + term;
if abs(term) < eps, break, end
end
a = sum_ak;
% Compute window coefficients
w(n/2+k+1) = alpha*besseli(0,a*sqrt(1-(k/M)^2));
w(n/2-k) = w(n/2+k+1);
end
% Normalize window to have unit energy
w = w / sqrt(sum(w.^2));
end
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)