Previous Up Next

21.3.4  Performing thresholding operations on an array

The threshold command changes data in an array by raising (or lowering) the values to meet a given threshold.

Examples

threshold([2,3,1,2,5,4,3,7],3)
     
[3,3,3,3,5,4,3,7]           
threshold([2,3,1,2,5,4,3,7],3=a,'>=')
     

2,a,1,2,a,a,a,a
          
threshold([-2,-3,1,2,5,-4,3,-1],3=0,abs=true)
     
[0,−3,0,0,5,−4,3,0]           
threshold([-2,-3,1,2,5,-4,3,-1],3=0,'<=',abs=true)
     

0,0,0,0,5,−4,0,0
          
threshold([-120,-11,-3,0,7,27,111,234],[-100,100])
     

−100,−11,−3,0,7,27,100,100
          
threshold([-120,-11,-3,0,7,27,111,234],[-100=-inf,100=inf])
     

−∞ ,−11,−3,0,7,27,+∞ ,+∞ 
          

In the following example, a square-like signal is created from a sine wave by clipping sample values.

data:=threshold(3*sin(2*pi*440*soundsec(2)),[-1.0,1.0]):; snd:=createwav(data):; plotwav(snd,range=[1000,2000])

Previous Up Next