Create an array (n,n) where only diagonal elements are '1' and others are '0' - MATLAB Cody - MATLAB Central

Problem 42456. Create an array (n,n) where only diagonal elements are '1' and others are '0'

Difficulty:Rate

Create an array (n,n) where only diagonal elements are '1' and others are '0'

EX: n = 3; then Resultant array would be [ 1 0 1

                                0 1 0
                                1 0 1 ]                                 

Solution Stats

66.67% Correct | 33.33% Incorrect
Last Solution submitted on Mar 02, 2025

Solution Comments

Show comments
Who Deserves Your Praise? Discover the New Contribution Widget!
...
We are excited to announce another update to our Discussions area: the...

Problem Recent Solvers84

Suggested Problems

More from this Author1

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page