Add SINGLE element to array or vector
显示 更早的评论
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 个评论
Image Analyst
2022-5-27
@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.
采纳的回答
更多回答(2 个)
Dakota Jandek
2020-4-7
2 个投票
x = [1, 2, 3]
x(length(x)+1) = 4
2 个评论
Adrien Bouguerra
2020-10-18
amazing method , really efficient thank u so much Dakota
Image Analyst
2020-10-18
Or even better,
x = [1, 2, 3]
x(end+1) = 4
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!