Remove the diagonal of a square matrix - MATLAB Cody - MATLAB Central

Problem 60727. Remove the diagonal of a square matrix

Difficulty:Rate
Some Cody problems ask solvers to remove columns (e.g., CP 7), and others ask solvers to remove rows (e.g., CP 44033).
Write a function to remove the main diagonal of a square matrix. For example, if the original matrix is
[1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25]
the resulting matrix would be
[6 11 16 21
2 12 17 22
3 8 18 23
4 9 14 24
5 10 15 20]
Elegance encouraged and appreciated.

Solution Stats

72.73% Correct | 27.27% Incorrect
Last Solution submitted on Feb 02, 2025

Problem Comments

Solution Comments

Show comments
Primes and Rough Numbers, Basic ideas
What is a rough number? What can they be used...
2
4

Problem Recent Solvers13

Suggested Problems

More from this Author291

Community Treasure Hunt

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

Start Hunting!
Go to top of page