# Matlab defining matrix

I'm new to matlab and the matlab's "get started" page on matrix doesn't seem to have instructions on how to define matrices such as this:

$A \in R^{n,n}$

$a_{i,j} = i^{j}, 1 \le i, j \le n$

how would I define non-static matrices like this on matlab? thank you

• You can do this with a for loop. – Nitin Oct 31 '16 at 12:43

Try this:

n = [whatever number you want];
A = zeros(n);

for i=1:n
for j=1:n
A(i,j) = i^j;
end
end


The idea is to make a zero matrix of the correct size and then fill the entries with a nested for loop.

• thank you, that makes sense – user3037568 Oct 31 '16 at 12:56