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 件のコメント

Torsten
Torsten 2021 年 5 月 30 日
You mean x = [x,[100,3]];
?
Sferle Alin-Tudor
Sferle Alin-Tudor 2021 年 5 月 30 日
編集済み: Sferle Alin-Tudor 2021 年 5 月 30 日
@TorstenNo, I want to add 3 to x 100 times. Sorry for bad explanation.
Torsten
Torsten 2021 年 5 月 30 日
x = [x,3*ones(1,100)];
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 日

2 投票

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 件のコメント

Sferle Alin-Tudor
Sferle Alin-Tudor 2021 年 5 月 30 日
編集済み: Sferle Alin-Tudor 2021 年 5 月 30 日
@KALYAN ACHARJYAOk, but if I want to add 3 digit 100 times in x how could I try?
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 件)

カテゴリ

ヘルプ センター および File ExchangeCreating 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