I find it more readable to determine first
rows = @(x) size(x,1); cols = @(x) size(x,2);
and then use, for example, the following:
for y = 1:rows(myMatrix) for x = 1:cols(myMatrix) do_whatever(myMatrix(y,x)) end end
It may look like a small saving, but size(.., 1) should be one of the most used functions.
(By the way, switching to such a matrix may not be the best choice for critical code. But if this is not a problem, go to the most readable choice.)
source share