Add SINGLE element to array or vector
Mostra commenti meno recenti
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 Commento
Image Analyst
il 27 Mag 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.
Risposta accettata
Più risposte (2)
Dakota Jandek
il 7 Apr 2020
2 voti
x = [1, 2, 3]
x(length(x)+1) = 4
2 Commenti
Adrien Bouguerra
il 18 Ott 2020
amazing method , really efficient thank u so much Dakota
Image Analyst
il 18 Ott 2020
Or even better,
x = [1, 2, 3]
x(end+1) = 4
Youssef AAKAM
il 13 Ott 2019
1 voto
x=[]
x=[x;'ysf']
Categorie
Scopri di più su Matrices and Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!