## Copyright (C) 2007 Andrei ## ## 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 2, 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, ## write to the Free Software Foundation, Inc., 51 Franklin Street, ## Fifth Floor, Boston, MA 02110-1301, USA. ## ## usage: YMOV*rect((VECTOR-XMOV)/WIDE) ## where: YMOV = Height of the pulse, movement up or down. ## XMOV = Movement to the right or left ## WIDE = Thickness of the pulse ## ## Rectangle function ## ## { 1.0 |t| < 0.5 ## rect(t) = { 0.5 |t| = 0.5 ## { 0.0 |t| > 0.5 ## ## Example1: ## rect(-2:2) ## => 0 0 1 0 0 ## ## Example2: ## t=-5:1/10:5; ## plot(t,rect(t)); ## ## Prints in a graphical interface: ## ## 1 ------- ## - - ## - - ## 0 ------------- -------------- ## ## -5 -4 -3 -2 -1 0 1 2 3 4 5 ## ## ## Author: Audreiev function result=rect(t) result = 1.*(abs(t)<0.5) + 0.5*(abs(t)==0.5); endfunction