Flip the diagonal values - MATLAB Cody - MATLAB Central

Problem 53114. Flip the diagonal values

Write a program that flip the elements of main diagonal , upper and lower diagonal values of a sqare matrix.
For example if a 3 x 3 matrix is an input of this function
A = [1 2 3; 3 2 1; 1 2 3]
then result would be
A = [3 1 3; 2 2 2; 1 3 1]
Hint: Use diag() and flip() functions

Solution Stats

25.15% Correct | 74.85% Incorrect
Last Solution submitted on May 15, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers78

Suggested Problems

Community Treasure Hunt

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

Start Hunting!