nxn matrix with elements from 1:n^2 - MATLAB Cody - MATLAB Central

Problem 59244. nxn matrix with elements from 1:n^2

Difficulty:Rate
input n defines the dimension of a square matrix to be filled from 1 to n^2 with 1 in upper left corner and n^2 in bottom right corner, numbers increasing from left to right across rows
examples:
n=1
1
n=2
1 2
3 4
n=5
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

Solution Stats

79.31% Correct | 20.69% Incorrect
Last Solution submitted on Jan 24, 2025

Solution Comments

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

Problem Recent Solvers19

Suggested Problems

More from this Author3

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