view scripts/signal/private/triangle_sw.m @ 31664:505ed551e366 stable

doc: Ensure DOCSTRING has an output when function returns a value (bug #61681) * @ftp/loadobj.m, @ftp/saveobj.m, __imfinfo__.m, __imread__.m, colorspace_conversion_revert.m, imageIO.m, imwrite_filename.m, ind2x.m, feval.m, check_default_input.m, odemergeopts.m, runge_kutta_interpolate.m, getsavepath.m, validsetargs.m, : Add missing Texinfo documentation block. * record.m, __file_filter__.m, uipushtool.m, isequalwithequalnans.m, __axis_label__.m, __axis_limits__.m, __bar__.m, __plt__.m, ifftshift.m, triangle_sw.m, bin2dec.m, __run_test_suite__.m : Add output to @deftypefn declaration.
author Rik <rik@octave.org>
date Mon, 12 Dec 2022 14:35:46 -0800
parents 796f54d4ddbf
children 597f3ee61a48
line wrap: on
line source

########################################################################
##
## Copyright (C) 1995-2022 The Octave Project Developers
##
## See the file COPYRIGHT.md in the top-level directory of this
## distribution or <https://octave.org/copyright/>.
##
## This file is part of Octave.
##
## Octave is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <https://www.gnu.org/licenses/>.
##
########################################################################

## -*- texinfo -*-
## @deftypefn {} {@var{retval} =} triangle_sw (@var{n}, @var{b})
## Triangular spectral window.
##
## Subfunction used for spectral density estimation.
## @seealso{spectral_xdf}
## @end deftypefn

function retval = triangle_sw (n, b)

  retval = zeros (n,1);
  retval(1) = 1 / b;

  l = (2:n)' - 1;
  l = 2 * pi * l / n;

  retval(2:n) = b * (sin (l / (2*b)) ./ sin (l / 2)).^2;

endfunction