Filter löschen
Filter löschen

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

6 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Feb. 2022
repelem()

Weitere Antworten (1)

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

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by