Add SINGLE element to array or vector
Afficher commentaires plus anciens
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 commentaire
Image Analyst
le 27 Mai 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.
Réponse acceptée
Plus de réponses (2)
Dakota Jandek
le 7 Avr 2020
2 votes
x = [1, 2, 3]
x(length(x)+1) = 4
2 commentaires
Adrien Bouguerra
le 18 Oct 2020
amazing method , really efficient thank u so much Dakota
Image Analyst
le 18 Oct 2020
Or even better,
x = [1, 2, 3]
x(end+1) = 4
Youssef AAKAM
le 13 Oct 2019
1 vote
x=[]
x=[x;'ysf']
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!