Filling a 2D matrix in numpy using a for loop
<p>I'm a Matlab user trying to switch to Python.</p>

<p>Using Numpy, how do I fill in a matrix inside a <code>for</code> loop?</p>

<p>For example, the matrix has 2 columns, and each iteration of the <code>for</code> loop adds a new row of data.</p>

<p>In Matlab, this would be:</p>

<pre><code>n = 100;
matrix = nan(n,2); % Pre-allocate matrix
for i = 1:n
    matrix(i,:) = [3*i, i^2];
end
</code></pre>