If your matrix is actually stored in a special sparse matrix data structure then you can do even better. Anyway, you could try using Matlab's sparse matrix routines and exporting to C. Otherwise, ...