fieldmatrix = (range<0.1)*selffield + (0.1<=range)*otherfield Make selffield a sparse matrix? It's still wasteful in that it does uneeded sparse matrix lookups and adds the resulting zeros.