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 次查看(过去 30 天)
显示 更早的评论
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 个评论
Steven Lord
2019-11-1
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!