creating an 8x8 matrix using "diag"

2 views (last 30 days)
So im trying to create an 8x8 matrix with 2's in the diagonal but 0s everywhere else. I used diag(8,8)*0 + 2 but that gived me 2's everywhere.

Accepted Answer

James Tursa
James Tursa on 22 Jan 2020
2*eye(8)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!