Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mufflon

macrumors 6502
Sep 15, 2006
264
2
I believe the syntax for a for-loop in mathlab is ? for i=1:12 - or something like that. write "help for" or "man for" (dunno which to get manual) directly in matlab main window.

edit: I was indeed correct
Code:
for loop variable = startvalue : endvalue 
     commands
end
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
mufflon said:
I believe the syntax for a for-loop in mathlab is ? for i=1:12 - or something like that. write "help for" or "man for" (dunno which to get manual) directly in matlab main window.

edit: I was indeed correct
Code:
for loop variable = startvalue : endvalue 
     commands
end

thanks, it worked with that. but now if i put i only owe $20, it still goes through all 12 months
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
well i would like to thank all who have helped me in this thread. i've finally got it working right, now i've just got to do the finishing touches and stuff

i still might have a few questions, but the program is working (i think at least)
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
well it looks like i'm still having a little trouble. and it's due tomorrow

how can i make my program stop after a certain amount of years? like 40?

you don't have to write the code for me, just an example of stopping a program after a certain time or whatever.

since i have a while loop, this might be complicated?
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
well, i've tried a break, and it stops it, but it's still not quite right.

i'm using all months, then converting to years and months. i have an if statement at the end of everything, saying if months < 480, then display a message.

else, display another message

but when i make it where it should take more than 480 months, the break stops it at 480, and it always displays the message that i don't want it too
 

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
twoodcc said:
well, i've tried a break, and it stops it, but it's still not quite right.

i'm using all months, then converting to years and months. i have an if statement at the end of everything, saying if months < 480, then display a message.

else, display another message

but when i make it where it should take more than 480 months, the break stops it at 480, and it always displays the message that i don't want it too

well i think i figured it out. i just had to move that if statement up past where i converted the months to years
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.