0
$\begingroup$

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

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

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.

$\endgroup$
1
  • $\begingroup$ thank you, that makes sense $\endgroup$ – user3037568 Oct 31 '16 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.