Here is my if loop:
loopcount = 0; TotalEnrolledNew = 0; if TotalEnrolledNew < 10000; x11(1) = 1500; x22(1) = 1400; x33(1) = 1300; for k = 1:1:14 x11(k+1) = 0.1 * x11(k) + 2900 + 100 * k; x22(k+1) = 0.75 * x11(k) + 0.05 * x22(k) + 250 + 50 * k; x33(k+1) = 0.9 * x22(k) + 0.05 * x33(k);end TotalEnrolledNew = x11(k) + x22(k) + x33(k)loopcount = loopcount + 1 else x111(1) = x11(loopcount); x222(1) = x22(loopcount); x333(1) = x33(loopcount);for k = 1:1:14 x111(k+1) = 0.1 * x111(k) + TotalEnrolledNew; x222(k+1) = 0.75 * x111(k) + 0.05 * x222(k) + 300; x333(k+1) = 0.9 * x222(k) + 0.05 * x333(k);endTotlEnrolledNew2 = x111(15) + x222(15) + x333(15) end
The idea is quite blatant, to follow the first set of rules until TotalEnrollmentNew is greater than 10000, then follow the new set of rules using TotalEnrolledNew in its first iteration. My issue is that loopcount stays at 1 in the ouput, and i think this is because of the use of the first for loop meaning the program loops within the if loop, so doesn't loop correctly. I have tried doing the following without the for loop but can't make any headway.
Any and all help appreciated as always
Best Answer