MATLAB: For loop data into 21X21 matrix.

loopsmatrix

I am trying to write a basic code that can take inputs from a for loop that is running a geometric function and write them into a matrix that needs to be square. 2X2, 100X100, whatever. I cannot find where to even start to write loop data into matrices.

Best Answer

E.g., a basic outline:
M = number of rows
N = number of columns
result = zeros(M,N); % pre-allocate result
for n=1:N
for m=1:M
result(m,n) = whatever; % insert your calculation code here
end
end
Related Question