This page contains the Matlab files used to generate the relevant data and graphs for my paper with Ó Cathain and Zhao, along with further information on parameters etc.


  • randomKSparseVector
  • This algorithm generates the k-sparse vectors used in our simulations. For clarity, in all experiments used to generate data for the paper, unless otherwise specified, the non-zero entries are drawn from a uniform distribution on the open interval (0,1). However, varying the distribution from which these entries are drawn still produces data which bolsters the case for sparsification of the sensing matrices - Figure 3 of the paper, for example, used vectors whose entries were drawn from a normal distribution.

  • generateMat
  • This algorithm is used to generate our original matrices - the unsparsified versions - from arguments corresponding to size and the distribution from which the entries were drawn. All matrices, and vectors, are normalised upon construction.

  • testOneMat
  • This algorithm takes, as its arguments, the parameters required to generate a matrix and a vector, and also a list of densities (corresponding to the desired levels of sparsification). A matrix is created, and then a sparsification thereof for each entry in the list of densities. Then, for each of these sparsified matrices Φ , a random k-sparse vector v is created and a recovery algorithm employed to attempt to recover v from Φv and Φ. A list of 0s (failures) and 1s (successes) is returned, with one entry corresponding to the recovery attempt for each sparsification. A recovery is deemed successful if the norm of the estimated vector differs from v by less than 10-6.

  • sparseCoefficientMat
  • This algorithm creates a matrix of a given size, where some given proportion of the entries in each column are randomly assigned to have value 1 and the rest are 0.

  • sparsifyMat
  • This algorithm returns a sparsification of the inputted matrix, whose density is some user-specified value between 0 and 1, created by taking an entrywise product of the inputted matrix with a sparseCoefficientMat.

  • findRx
  • This function finds Rx for a given matrix size and density, ie. the maximum value k for which we can say with x% certainty that our recovery algorithm will successfully recover a k-sparse vector. Throughout the paper, we used x=98%.

  • sparsitySuccessTest
  • For each of an inputted range of vector sparsities and matrix and matrix densities, this test returns the number of successful recoveries over a given number of iterations.

    A figure similar to Figure 1 can be generated using
  • generateSparsitySuccessTestGraph.m
  • . The parameters used in our example were
    generateSparsitySuccessTestGraph(200,2000,'N',[1,0.1,0.05],30,60,500); where
    • 200x2000 are the dimensions of the matrices we consider
    • 'N' indicates that the entry values in the matrices are normally distributed (though we then take the absolute value)
    • [1,0.1,0.05] are the sparsification levels we test - 1 being the original matrix and 0.05 containing 95% zero entries
    • 30 and 60 are the lower and upper bounds on the sparsity of the signal
    • 500 is the number of iterations over each matrix sparsity level
    • (Data is sent to sparsitySuccessTestGraphData.txt by default)


    A figure similar to Figure 2 can be generated using
  • generateFindRxGraph.m