This question is closed. Reopen it to edit or answer.
How to subtract the elements of an array
1 view (last 30 days)
Show older comments
Hugo on 10 Sep 2020
Closed: Ameer Hamza on 10 Sep 2020
I am coding an .m file in MATLAB R2018a. The code I have (partial) is:
As you can see, I am trying to subtract the 2nd element of the array is subtracted to the 1st and place it on the index 1 of the array grad(i). Then, the 3rd element of the array is subtracted to the 2nd and place it on the index 2 of the array grad(i). By last, the 4th element of the array to the 3rd and place it on the index 3 of the array grad(i)
Then, all the elements of the array grad(i) are sum into the variable sumgrad.
I am getting this error:
Error: Index exceeds array bounds.
I am quite sure there is a better way of coding this. Could someone help me?
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!