Generate matrix that is a product of its indices

2 views (last 30 days)
I need to generate an n-by-n matrix, M. The n-by-n matrix elements are given by the product of its indices, M_ij=i*j-(i+j). I'm not very experienced with Matlab. How would I go about this?

Accepted Answer

Bruno Luong
Bruno Luong on 23 Aug 2019
Edited: Bruno Luong on 23 Aug 2019
n = 5;
i = (1:n)';
j = 1:n;
M = i.*j - (i+j)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!