Advertisement
uaelite

Untitled

Sep 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. function [m,a] = IRA(s,r)
  2. if isempty (s) s = 100; end %Spent hours on this, doesn't work
  3. if isempty (r) r = 5; end %Despite coming straight out of lecture slides
  4.  
  5. % m is variable for months
  6. % a is variable for total amount
  7. % s is variable for savings per month
  8. % r is variable for interest rate
  9.  
  10. m = 0;
  11. a = s * (1 + r/1200);
  12.  
  13. while(m < 600 && a < 1000000)
  14. if a < 1000000
  15. a = s + a * (1 + r/1200);
  16. m = m + 1;
  17. elseif a >= 1000000
  18. m = m + 1;
  19. a = s + a * (1 + r/1200);
  20. end
  21. end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement