Sparsity for ultrafast material identification