I have no idea how to do this
Show older comments
My professor just started going over programming in MATLAB however he is not doing anything close to a good job of explaining it. my current assignment is
Given the array Y from the last homework assignment. Write a program that will add the terms of the array, one at a time, until the total is equal to or greater than 3500. Out put the value of the last element that was added.
Y = [95 93 69 75 74 88 83 91 90 78 89 88 86 79 80 55 32 100 97 81 70 ...
75 77 96 83 86 74 91 89 92 79 70 83 88 91 100 76 41 73 71 79 94 ...
105 92 89 89 87 66 94 97 92 78 84 89 ]
I have absolutely no idea how to go about this and i have no experience with programming. Does anyone know how to do this?
5 Comments
Jan
on 29 Sep 2012
Your professor knows this forum also. If you want to criticize him, I suggest to do this personally, but not in a public forum.
Image Analyst
on 29 Sep 2012
Have you taken any programming at all before? Adding (accumulating) something in a loop is reall, really basic stuff and is almost the same in every language, so you'd already know that if you took any kind of programming course at all before now. To get out of a loop, you call "break" - just like you do in C and some other languages. The "if" test you'll use is also pretty much the same except that there are no parentheses needed around the condition, and there is nothing to start the block, like no "{" or no "then" or no "begin" needed. And all loops end with the same single word "end".
Matt Fig
on 29 Sep 2012
There is a little button that looks like this '{} Code' please highlight your code and the press that button in the future. Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!