I'm a Matlab user trying to switch to Python.
Using Numpy, how do I fill in a matrix inside a for
loop?
For example, the matrix has 2 columns, and each iteration of the for
loop adds a new row of data.
In Matlab, this would be:
n = 100;
matrix = nan(n,2); % Pre-allocate matrix
for i = 1:n
matrix(i,:) = [3*i, i^2];
end