v_modsym

PURPOSE ^

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

SYNOPSIS ^

function z=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)
          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|

 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
      Version: $Id:  $

   VOICEBOX is a MATLAB toolbox for speech processing.
   Home page: http://www.ee.ic.ac.uk/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 General Public License as published by
   the Free Software Foundation; either version 2 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 General Public License for more details.

   You can obtain a copy of the GNU General Public License from
   http://www.gnu.org/copyleft/gpl.html or by writing to
   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function z=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)
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 %
0012 % v_modsym(x,y,r) adds an integer multiple of y onto x so that it lies in
0013 % the range [r-y/2,r+y/2) if y is positive or (r-y/2,r+y/2] if y is negative.
0014 %
0015 %      Copyright (C) Mike Brookes 2024
0016 %      Version: $Id:  $
0017 %
0018 %   VOICEBOX is a MATLAB toolbox for speech processing.
0019 %   Home page: http://www.ee.ic.ac.uk/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 General Public License as published by
0024 %   the Free Software Foundation; either version 2 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 General Public License for more details.
0031 %
0032 %   You can obtain a copy of the GNU General Public License from
0033 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0034 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0036 if nargin<3
0037     v=0.5*y;
0038 else
0039     v=0.5*y-r;
0040 end 
0041 z=mod(x+v,y)-v;

Generated by m2html © 2003