adding vector entry after each element
1 次查看(过去 30 天)
显示 更早的评论
This is a very basic question but how would I add the elements of a vector like so...:
x = [1,2,3,4,5,6];
ans = 3 6 10 15 21
0 个评论
采纳的回答
更多回答(1 个)
Sean de Wolski
2012-8-15
And just for fun:
filter(x(2:end),1,ones(1,numel(x)-1))+x(1)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!