Subtracting two arrays Matlab
显示 更早的评论
this may sound awkward, i tried a loop but i am getting error(attempt to access), what i am trying to do is subtracting 2 arrays
A=[0;10;20;30;40]
V(1,1)=100 it starts with one value then changes its dimension to obtain V(2,1)=V(1)-A(1) and V(3,1)=V(2)-A(1) and the result will be
V= [100;90;70;40;0]
i also tried `cumsum` , but may be i didn't use it right !
2 个评论
Walter Roberson
2016-1-12
Does A(2) ever get used in the calculation?
sami elahj
2016-1-12
编辑:sami elahj
2016-1-12
回答(1 个)
the cyclist
2016-1-12
A = [0;10;20;30;40]
V = 100 - cumsum(A);
类别
在 帮助中心 和 File Exchange 中查找有关 Sparse Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!