How can I solve this matrix problem?

1 view (last 30 days)
Nguyen Vinh
Nguyen Vinh on 4 Jun 2021
Answered: Jonas on 4 Jun 2021

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 4 Jun 2021
You can start working with eye() and rot90()
Then you can try with for loop, i.e. [for .. end] and [while .. end]
  1 Comment
Nguyen Vinh
Nguyen Vinh on 4 Jun 2021
Unfortunately, my teacher doesn't allow me to use rot90()

Sign in to comment.


Jonas
Jonas on 4 Jun 2021
Use a for-loop which goes from 1:n over the two dimensions, and use an if-statement to write a 1 and an else statement to write a 0, pending on if we comply with being on that diagonal.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!