Presidential election predictor using matrix-processing
Replacing loops in MATLAB with equivalent matrix operations (a technique commonly referred to as vectorization) often, but not always, leads to improvements in performance. However, this frequently results in code that may be difficult for others to read, so it is advisable to use the profiler to identify bottlenecks and then try vectorizing only those sections of code where performance really matters. You could do something like this (outside the loop):

voteMatrix(regions == 6) = -1


This is equivalent to the first if condition in your loop. Try to do the same to the else condition. (Hint: you'll need to update your voteFromLocation method to handle arrays in the same manner.)

It's been a long time since I last used MATLAB, so my syntax may not be very accurate, but you get the general idea.