Huw to create counter?
99 次查看(过去 30 天)
显示 更早的评论
"Counters are useful programming tools, for example, to keep track of how many times a command has been executed. Create a counter in the variable r and set it to 1. Then write a loop that increases for each turn on the counter by one and then adds the value of the counter to a sum. Save the sum to the variable sum. The loop should go between 1 and 10"
I've gotten this task and the starting code below. But I don't understand what to do? (Just learning matlab)
r = ?
sum = +
for k = ?
r ?
sum?
end
采纳的回答
Anna Nordin
2019-9-3
1 个评论
Adam Danz
2019-9-3
That was my interpretation of the problem, too. Just be sure to never have a variable named "sum" as is written in the instructions.
更多回答(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!