diff --git a/zUtil_Cxx/CompressiveSensing/gtSoftThreshold.cpp b/zUtil_Cxx/CompressiveSensing/gtSoftThreshold.cpp
index 32264fca31b20e6dbc8fb40c0412fdf594c40b38..bf73d80f19f7f3dc44da90e78ce5e05c8f7fbb4d 100755
--- a/zUtil_Cxx/CompressiveSensing/gtSoftThreshold.cpp
+++ b/zUtil_Cxx/CompressiveSensing/gtSoftThreshold.cpp
@@ -32,10 +32,11 @@ void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[] )
     }
   }
 
-  const double * const __restrict inData = mxGetPr(prhs[0]);
-  double * const __restrict outData = mxGetPr(prhs[1]);
-
-  soft_threshold<mwSize, double> thr(*mxGetPr(prhs[1]));
+  double threshold = 0;
+  if (mxGetNumberOfElements(prhs[1]) != 0) {
+    threshold = *mxGetPr(prhs[1]);
+  }
+  soft_threshold<mwSize, double> thr(threshold);
 
   const mwSize numElems = mxGetNumberOfElements(prhs[0]);
   if (copy) {