I\'m writing a simulation in Matlab. I will eventually run this simulation hundreds of times. In each simulation run, there are millions of simulation cycles. In each of the
For a large list, a hand-coded binary search can beat ismember, if maintaining it in sorted order isn't too expensive. If that's really your bottleneck. Use the profiler to see how much the ismember is really costing you. If there aren't too many distinct values, you could also store them in a containers.Map by packing the bit_matrix in to a char
array and using it as the key.
If it's small enough to fit in memory, you could store it in a MAT file using save
and load
. They can store any basic Matlab datatype. Have the simulation save
the accumulated res
and bit_matrix
at the end of its run, and re-load
them the next time it's called.