%Code written by Namrata Vaswani
%If you use this code, please cite: 
%N. Vaswani, Kalman Filtered Compressed Sensing, ICIP 2008
%N. Vaswani, Analyzing Least Squares and Kalman Filtered Compressed Sensing, ICASSP 2009

Main file: runsims_final.m

This file contains the following parts.

0. set paramaters
Specify sigma0 (sigma_obs in the paper), sigsys (sigma_sys), siginit. 
Alternatively directly specify R, Q, Pi0. 
Set total_iters (number of realizations to average over)
Set tot (total time, T)

1. gendata_full
a. simulates x(:,t) and y(:,t) = Ax(:,t) + w_t
b. A = random Gaussian matrix (replace this by the desired matrix for your problem)
c. x(:,t) follows a Gaussian random walk model, and support increases slowly (see code or ICASSP'09 for details)

d. to run code on real data, comment out gendata_full and
- save measurements into y(:,t), for all t. y is n x tot. 
- x(:,t) is the coefficients in the sparsity basis
- A = (measurement matrix)*(sparsity basis)
e.g if running dynamic MRI reconstruction with wavelets as sparsity basis
A = (H*F)*W' where H_{n x m} =random row sampling matrix, F_{m x m} = DFT matrix, W = 2D-DWT matrix. 
(compute W by applying DWT2 to each column of identity matrix). 
- Specify sigma0 (sigma_obs in the paper), sigsys (sigma_sys), siginit. 
  Alternatively directly specify R, Q, Pi0. See 0. above.
- set total_iters = 1

2.  if run_kfcs==1,
a. calls 6 functions to run the following 6 algorithms and the genie-KF 
LS-CSresidual-LS (lscs), KF-CSresidual-LS (kfcsls) and KF-CSresidual-KF (kfcs), 
each with and without deletion step and the genie KF. 

b. computes MSE's of each of them. saves data into a file. 

c. CSresidual uses Dantzig Selector to solve the noisy-CS problem: can replace this by BPDN for more efficient methods
d. Also should replace linprog by code from CVX 

3. if run_cs==1,
a. runs CS-noiseless (regularcs_no_noise), CS Dantzig-Selector (regularcs) 
b. computes MSE's. saves data into a file. 

4. if sim==0
Code for plotting, either set sim=0 or just copy-paste code to plot MSEs etc.

