How to create an array with first 100 elements as 1, next 100 as 2 and so on?

5 visualizaciones (últimos 30 días)
I want to create an array which looks like this:
[1 1 1 1 ...(100 time), 2 2 2 2...(100 times), 3 3 3 3....]
like this.
I'm very new to matlab, Any help?

Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de Feb. de 2022
repelem()
  1 comentario
Sahil Islam
Sahil Islam el 26 de Feb. de 2022
Can you give a proper code. Like repelem() does that. But how to make one array of all those?

Iniciar sesión para comentar.

Más respuestas (1)

Vineet Kuruvilla
Vineet Kuruvilla el 26 de Feb. de 2022
n = 5;
A=[];
for i = 1 : 5
A=vertcat(A,i*ones(1,100));
end
disp(A)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by