Using Sparse Representation to Detect Anomalies in Complex WSNs