Matlab Practice

edited March 2009 in Science & Tech
I am doing a practice exam for my test tomorrow, but there is no answer key....

It's problem 3 from:

http://remus.rutgers.edu/cs107/2007/fall/exams/f07-exam1.pdf

I have:

function draft=overdraft(balances)
total=0;
largest=min(balances);
for place=1:length(balances);
if place(balances)<0
total=total+1
end
disp([largest total])
end

When I tried this out with matlab, the "largest" works, but it just returns 0 for the number of overdrafts everytime. I don't know if he intends for us just to use the "min" function to find the largest overdraft either....maybe there's a different way like comparing each balance...but I don't know. What is the answer?

Comments

  • edited March 2009
    no one knows?
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited March 2009
    place(balances)

    you're still doing indexing wrong.

    place is your index, balances is your vector

    balances(place) is what you want
Sign In or Register to comment.