protip, if you don’t care about flow control like continue and break, you can write nested loops really easily with:
for i=1:I, j=1:J, k=1:K
# blah
end
the j loop is the most tightly nested, and the i loop is the outer loop.
anyway, I’m too lazy to check if this has the dimensions you’re looking for, but you might consider this:
v = [[SomeFunction(10,15,9) for imat21=1:sizeMat21, imat22=1:sizeMat22] for imat12=1:sizeMat12, imat21=1:sizeMat21]
you can also make a 4-d array, in case that makes things easier in any way:
v = [SomeFunction(10,15,9) for imat21=1:sizeMat21, imat22=1:sizeMat22, imat12=1:sizeMat12, imat21=1:sizeMat21]
list comprehensions have the nice feature of not needing to think through entirely ahead of time the proper allocation structure.