Matlab defining matrix

60 Views Asked by At

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

1

There are 1 best solutions below

1
On BEST ANSWER

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.