bpdq_generate_1d_signal

PURPOSE ^

bpdq_generate_1d_signal : Generate random sparse signal

SYNOPSIS ^

function x = bpdq_generate_1d_signal(N,K,seed)

DESCRIPTION ^

 bpdq_generate_1d_signal : Generate random sparse signal

 x = bpdq_generate_1d_signal(N,K,seed)
 Generates N length K sparse random signal 
 (K nonzero entries are iid zero mean Gaussian  with unit variance)

 Inputs :
 N - Signal length
 K - sparsity
 seed - (optional) seed for random number generator

 Outputs:
 x- returned random signal

 This file is part of BPDQ Toolbox (Basis Pursuit DeQuantizer)
 Copyright (C) 2009, the BPDQ Team (see the file AUTHORS distributed with
 this library) (See the notice at the end of the file.)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % bpdq_generate_1d_signal : Generate random sparse signal
0002 %
0003 % x = bpdq_generate_1d_signal(N,K,seed)
0004 % Generates N length K sparse random signal
0005 % (K nonzero entries are iid zero mean Gaussian  with unit variance)
0006 %
0007 % Inputs :
0008 % N - Signal length
0009 % K - sparsity
0010 % seed - (optional) seed for random number generator
0011 %
0012 % Outputs:
0013 % x- returned random signal
0014 %
0015 % This file is part of BPDQ Toolbox (Basis Pursuit DeQuantizer)
0016 % Copyright (C) 2009, the BPDQ Team (see the file AUTHORS distributed with
0017 % this library) (See the notice at the end of the file.)
0018 
0019 function x = bpdq_generate_1d_signal(N,K,seed)
0020   if (nargin==3)
0021     rand('seed',seed);
0022     randn('seed',seed);  
0023   end
0024   x = zeros(N,1);
0025   pos = randperm(N);
0026   x(pos(1:K)) = randn(K,1);
0027   
0028 % The BPDQ Toolbox is free software: you can redistribute it and/or modify
0029 % it under the terms of the GNU General Public License as published by
0030 % the Free Software Foundation, either version 3 of the License, or
0031 % (at your option) any later version.
0032 %
0033 % The BPDQ Toolbox is distributed in the hope that it will be useful,
0034 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0035 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0036 % GNU General Public License for more details.
0037 %
0038 % You should have received a copy of the GNU General Public License
0039 % along with The BPDQ Toolbox.  If not, see <http://www.gnu.org/licenses/>.

Generated on Mon 06-Jul-2009 14:16:10 by m2html © 2003