필터 지우기
필터 지우기

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

조회 수: 21 (최근 30일)
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?

채택된 답변

Walter Roberson
Walter Roberson 2022년 2월 26일
repelem()
  댓글 수: 1
Sahil Islam
Sahil Islam 2022년 2월 26일
Can you give a proper code. Like repelem() does that. But how to make one array of all those?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Vineet Kuruvilla
Vineet Kuruvilla 2022년 2월 26일
n = 5;
A=[];
for i = 1 : 5
A=vertcat(A,i*ones(1,100));
end
disp(A)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by