Add SINGLE element to array or vector
Mostrar comentarios más antiguos
I have a vector of the format:
x = [xval(1) xval(2) … xval(n)]
, and I want to add an element to the end, xval(n+1). How do I do that?
1 comentario
Image Analyst
el 27 de Mayo de 2022
@Anushalini Thiyagarajan I have no idea what you mean. Please ask your question in a new question (not here) after you read this:
In the meantime, look at input functions such as readmatrix, importdata, dlmread, xlsread, fgetl, etc.
Respuesta aceptada
Más respuestas (2)
Dakota Jandek
el 7 de Abr. de 2020
2 votos
x = [1, 2, 3]
x(length(x)+1) = 4
2 comentarios
Adrien Bouguerra
el 18 de Oct. de 2020
amazing method , really efficient thank u so much Dakota
Image Analyst
el 18 de Oct. de 2020
Or even better,
x = [1, 2, 3]
x(end+1) = 4
Youssef AAKAM
el 13 de Oct. de 2019
1 voto
x=[]
x=[x;'ysf']
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!