How can I change elements in a matrix all at once??
Show older comments
How can I change each element in a matrix so that each new element is for example itself + the element next to it?
Answers (2)
This seems to be a job for cumsum. A small example would clear the details.
[EDITED] After your comment: NO, not cumsum. See Kelly's answer.
1 Comment
Ken Mills
on 25 Sep 2013
Kelly Kearney
on 25 Sep 2013
new = mtx + [mtx(:,2:end) zeros(size(mtx,1),1)]
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!