Generate a matrix as follows - MATLAB Cody - MATLAB Central

Problem 52193. Generate a matrix as follows

Difficulty:Rate
write a Function that gives like the following for a random n:
n=2
ans= [ 0 1
1 0]
n=6
ans=
[ 0 1 2 3 4 5
1 0 1 2 3 4
2 1 0 1 2 3
3 2 1 0 1 2
4 3 2 1 0 1
5 4 3 2 1 0]
Goodluck

Solution Stats

64.71% Correct | 35.29% Incorrect
Last Solution submitted on May 08, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers29

Suggested Problems

More from this Author5

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