Add n+1 element to a vector
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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?
ex: x = [ 1 4 2 8]
newX = [ 1 4 2 8 9]
0 Commenti
Risposta accettata
Peng Li
il 10 Apr 2020
If your X is a row vector, using newX = [X, aNewElement];
If your X is a column vector, using newX = [X; aNewElement];
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices 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!