> I am puzzled by your two earlier lines: > > ec = zeros(rows+1, cols, riskLevels); > ec(1, :, :) = 100; > > where riskLevels = 3. If this is what you really do, you ought to get error messages stating that ec(r-1,c,risk) on the right side is undefined on the first trip through the three nested for-loops with risk = 6. In any case this would certainly make your execution very slow. The 'ec' array needs to be pre-defined up to risk = 18 in the third dimension of your allocation if the nested loops are going to extend it that far. > > Roger Stafford
You're right there...the risk level values I posted are not really the values I'm working with.
Over the last hour I've done some testing with your vectorized version of the code and I noticed that the vectorized version (for whatever reason) seems to be slower than the original version - and the differences in speed become worse the larger the input data are.