MATLAB: How to add a For Loop Matrix Indicator

for loopmatrix

I am new to Matlab and have been away from programming for 20+ years. I want to keep track of a matrix via a for loop. That is, as the loop iterates, I want to create a different matrix for each loop. If I was looping
for el = 1:6 A = zeros(24×24) A = bunch of math end
I need to end up with 6 matrices, one for each loop of el.
How do you add the el index to the matrix? I tried all kinds of variations of A(el) = stuff; A{el} = stuff and none of it works.
Please help.

Best Answer

You would do this, instead,
for el=1:2
....
K(:,:,el) = 5 * J % I need K(el) ie K(1) and K(2)
end
Instead of K(1) and K(2) you would index as K(:,:,1) and K(:,:,2)