Add element to a given vector
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
steve Brian
il 10 Apr 2020
Commentato: steve Brian
il 10 Apr 2020
I have a vector of the format:
x = [X1 X2 … Xn]
I want to add an element to the end, X(n+1). How do I do that?
x = [ X1 X2 .. Xn X(n+1) ]
ex: x = [ 1 4 2 8]
newX = [ 1 4 2 8 9]
A little help, please!
0 Commenti
Risposta accettata
per isakson
il 10 Apr 2020
Modificato: per isakson
il 10 Apr 2020
One way
>> x = 1:6
x =
1 2 3 4 5 6
>> x(end+1)=17
x =
1 2 3 4 5 6 17
>>
5 Commenti
per isakson
il 10 Apr 2020
I'm even more confused
"I have already the newV, but i want to add that n+1 element"
Isn't that exactly what's done by
NewV(end+1) = 22;
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!