Add multiple elements to array

조회 수: 102 (최근 30일)
Sferle Alin-Tudor
Sferle Alin-Tudor 2021년 5월 30일
댓글: David Horton 2021년 12월 23일
Hi,
Is there possible to add more than one element to an array at the same time?Like in this array:
x=[];
x=[x,3];%and I want to add a number of 100 3 in x
  댓글 수: 5
Sferle Alin-Tudor
Sferle Alin-Tudor 2021년 9월 21일
Thanks you @Torsten
David Horton
David Horton 2021년 12월 23일
Thanks!!!!!!

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

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 5월 30일
편집: KALYAN ACHARJYA 2021년 5월 30일
Yes it's OK, horizontal concatenation
x=[x,3]
Example:
>> x=1:4
x =
1 2 3 4
>> x=[x,9:12]
x =
1 2 3 4 9 10 11 12
  댓글 수: 3
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 5월 30일
편집: KALYAN ACHARJYA 2021년 5월 30일
See the repmat (Copiese array n times horizantly)
x= repmat(x , [1,n]) ;
e.g.
x =
1 2 3
>> x=repmat(x,[1,3])
x =
1 2 3 1 2 3 1 2 3
If this is not looking for then, please see the @Torsten comment
Still not see repelem
Sferle Alin-Tudor
Sferle Alin-Tudor 2021년 9월 21일
Thank you very much

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by