Add element to a given vector
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
steve Brian
el 10 de Abr. de 2020
Comentada: steve Brian
el 10 de Abr. de 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 comentarios
Respuesta aceptada
per isakson
el 10 de Abr. de 2020
Editada: per isakson
el 10 de Abr. de 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 comentarios
per isakson
el 10 de Abr. de 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;
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!