Add element to a given vector
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
per isakson
2020-4-10
编辑:per isakson
2020-4-10
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 个评论
per isakson
2020-4-10
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;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!