How do I create a (10,10) matrix containing numbers from 1 to 100?

159 visualizaciones (últimos 30 días)
Tom
Tom el 18 de Sept. de 2013
Comentada: DGM el 13 de Mayo de 2024
How do I create a (10,10) matrix containing numbers from 1 to 100?
I just want the numbers to go 1 to 10 on the top row, then 11-20 on the 2nd row etc.
  2 comentarios
James Tursa
James Tursa el 18 de Sept. de 2013
Is this homework? What have you tried so far?
Tom
Tom el 18 de Sept. de 2013
I did it using
ij = [1:10 ; 11:20 ; 21:30 ; 31:40 ; 41:50 ; 51:60 ; 61:70 ; 71:80 ; 81:90 ; 91:100]
but Walter's is better obviously. I'm just getting going on my Master's dissertation in Audio Acoustics.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Sept. de 2013
reshape( 1:100, 10, 10) .'

Más respuestas (4)

Steven Lord
Steven Lord el 25 de En. de 2022
Another solution using implicit expansion (which wasn't available back in 2013 when this question was posted):
n = 10;
A = (1:n) + n*(0:n-1).'
A = 10×10
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

SYED ABOU ILTAF HUSSAIN
SYED ABOU ILTAF HUSSAIN el 2 de Sept. de 2018
Editada: SYED ABOU ILTAF HUSSAIN el 2 de Sept. de 2018
Try this a= [1:10]; for i=2:10 a(i,:)=a(i-1,:)+10; end

DGM
DGM el 25 de En. de 2022
Editada: DGM el 25 de En. de 2022
If we're posting solutions which are instructive, even if not ideal:
A = zeros(10);
A(:) = 1:100;
A = A.'
A = 10×10
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

finess
finess el 26 de Ag. de 2022
create a new 4x4 matrix that is filled with the number 100
  9 comentarios
finess
finess el 28 de Ag. de 2022
Wow I love these Answers! It gives me a feeling of how a great teacher looks like, with great options for students
DGM
DGM el 13 de Mayo de 2024
Flagged by 博文 on 23 Apr 2024:
GOOD

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by