Problem 60930. 'X'avier
Given a square matrix A of size n, write a function to create a new matrix B where only the elements on the main diagonal and the anti-diagonal are retained. All other elements should be set to zero.
For instance,
A = [1 2 3;
4 5 6;
7 8 9];
B = [1 0 3;
0 5 0;
7 0 9];
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers12
Suggested Problems
-
12 Solvers
More from this Author174
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!