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 commentaires

Torsten
Torsten le 30 Mai 2021
You mean x = [x,[100,3]];
?
Sferle Alin-Tudor
Sferle Alin-Tudor le 30 Mai 2021
Modifié(e) : Sferle Alin-Tudor le 30 Mai 2021
@TorstenNo, I want to add 3 to x 100 times. Sorry for bad explanation.
Torsten
Torsten le 30 Mai 2021
x = [x,3*ones(1,100)];
Sferle Alin-Tudor
Sferle Alin-Tudor le 21 Sep 2021
Thanks you @Torsten
David Horton
David Horton le 23 Déc 2021
Thanks!!!!!!

Connectez-vous pour commenter.

 Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 30 Mai 2021
Modifié(e) : KALYAN ACHARJYA le 30 Mai 2021

2 votes

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 commentaires

Sferle Alin-Tudor
Sferle Alin-Tudor le 30 Mai 2021
Modifié(e) : Sferle Alin-Tudor le 30 Mai 2021
@KALYAN ACHARJYAOk, but if I want to add 3 digit 100 times in x how could I try?
KALYAN ACHARJYA
KALYAN ACHARJYA le 30 Mai 2021
Modifié(e) : KALYAN ACHARJYA le 30 Mai 2021
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 le 21 Sep 2021
Thank you very much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Produits

Version

R2020b

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by