Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element. Ex: If bonusScores = [10, 20, 30, 40], then af

2 views (last 30 days)
Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last element which stays the same. Be careful not to index beyond the last element.
Ex: If bonusScores = [10, 20, 30, 40], then after the the loop bonusScores = [30, 50, 70, 40]
The first element is 30 or 10 + 20, the second element is 50 or 20 + 30, and the third element is 70 or 30 + 40. The last element remains the same.
this is the full question
Any help with this problem I am not sure how to set it up.
  1 Comment
Steven Lord
Steven Lord on 1 Nov 2019
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem or you don't understand what the question is asking, I recommend asking your professor and/or teaching assistant for help.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!