Cody

# Problem 44345. MATLAB Counter

Solution 1312535

Submitted on 24 Oct 2017 by Atnas
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','counter.m')

2   Pass
f = counter(0,1); assert(isequal(f(),0)) assert(isequal(f(),1)) assert(isequal(2,f())) assert(isequal(3,f()))

ans = function_handle with value: @counter/c a = 0 a = 1 a = 2 a = 3

3   Pass
f = counter(1,0); assert(isequal(f(),1)) assert(isequal(f(),1)) assert(isequal(1,f())) assert(isequal(1,f()))

ans = function_handle with value: @counter/c a = 1 a = 1 a = 1 a = 1

4   Pass
f = counter(10,2); assert(isequal(f(),10)) assert(isequal(f(),12)) assert(isequal(14,f())) assert(isequal(16,f()))

ans = function_handle with value: @counter/c a = 10 a = 12 a = 14 a = 16

5   Pass
f = counter(0,5); y_correct = [0, 5, 10, 15, 20, 55]; assert(isequal([f() f() f() f() f() f()+f()],y_correct))

ans = function_handle with value: @counter/c a = 0 a = 5 a = 10 a = 15 a = 20 a = 25 a = 30

6   Pass
x0 = randi(10); b = randi(10); f = counter(x0,b); y_correct = x0 + (0:1000)*b; assert(isequal(arrayfun(@(n)f(),0:1000),y_correct))

ans = function_handle with value: @counter/c a = 6 a = 13 a = 20 a = 27 a = 34 a = 41 a = 48 a = 55 a = 62 a = 69 a = 76 a = 83 a = 90 a = 97 a = 104 a = 111 a = 118 a = 125 a = 132 a = 139 a = 146 a = 153 a = 160 a = 167 a = 174 a = 181 a = 188 a = 195 a = 202 a = 209 a = 216 a = 223 a = 230 a = 237 a = 244 a = 251 a = 258 a = 265 a = 272 a = 279 a = 286 a = 293 a = 300 a = 307 a = 314 a = 321 a = 328 a = 335 a = 342 a = 349 a = 356 a = 363 a = 370 a = 377 a = 384 a = 391 a = 398 a = 405 a = 412 a = 419 a = 426 a = 433 a = 440 a = 447 a = 454 a = 461 a = 468 a = 475 a = 482 a = 489 a = 496 a = 503 a = 510 a = 517 a = 524 a = 531 a = 538 a = 545 a = 552 a = 559 a = 566 a = 573 a = 580 a = 587 a = 594 a = 601 a = 608 a = 615 a = 622 a = 629 a = 636 a = 643 a = 650 a = 657 a = 664 a = 671 a = 678 a = 685 a = 692 a = 699 a = 706 a = 713 a = 720 a = 727 a = 734 a = 741 a = 748 a = 755 a = 762 a = 769 a = 776 a = 783 a = 790 a = 797 a = 804 a = 811 a = 818 a = 825 a = 832 a = 839 a = 846 a = 853 a = 860 a = 867 a = 874 a = 881 a = 888 a = 895 a = 902 a = 909 a = 916 a = 923 a = 930 a = 937 a = 944 a = 951 a = 958 a = 965 a = 972 a = 979 a = 986 a = 993 a = 1000 a = 1007 a = 1014 a = 1021 a = 1028 a = 1035 a = 1042 a = 1049 a = 1056 a = 1063 a = 1070 a = 1077 a = 1084 a = 1091 a = 1098 a = 1105 a = 1112 a = 1119 a = 1126 a = 1133 a = 1140 a = 1147 a = 1154 a = 1161 a = 1168 a = 1175 a = 1182 a = 1189 a = 1196 a = 1203 a = 1210 a = 1217 a = 1224 a = 1231 a = 1238 a = 1245 a = 1252 a = 1259 a = 1266 a = 1273 a = 1280 a = 1287 a = 1294 a = 1301 a = 1308 a = 1315 a = 1322 a = 1329 a = 1336 a = 1343 a = 1350 a = 1357 a = 1364 a = 1371 a = 1378 a = 1385 a = 1392 a = 1399 a = 1406 a = 1413 a = 1420 a = 1427 a = 1434 a = 1441 a = 1448 a = 1455 a = 1462 a = 1469 a = 1476 a = 1483 a = 1490 a = 1497 a = 1504 a = 1511 a = 1518 a = 1525 a = 1532 a = 1539 a = 1546 a = 1553 a = 1560 a = 1567 a = 1574 a = 1581 a = 1588 a = 1595 a = 1602 a = 1609 a = 1616 a = 1623 a = 1630 a = 1637 a = 1644 a = 1651 a = 1658 a = 1665 a = 1672 a = 1679 a = 1686 a = 1693 a = 1700 a = 1707 a = 1714 a = 1721 a = 1728 a = 1735 a = 1742 a = 1749 a = 1756 a = 1763 a = 1770 a = 1777 a = 1784 a = 1791 a = 1798 a = 1805 a = 1812 a = 1819 a = 1826 a = 1833 a = 1840 a = 1847 a = 1854 a = 1861 a = 1868 a = 1875 a = 1882 a = 1889 a = 1896 a = 1903 a = 1910 a = 1917 a = 1924 a = 1931 a = 1938 a = 1945 a = 1952 a = 1959 a = 1966 a = 1973 a = 1980 a = 1987 a = 1994 a = 2001 a = 2008 a = 2015 a = 2022 a = 2029 a = 2036 a = 2043 a = 2050 a = 2057 a = 2064 a = 2071 a = 2078 a = 2085 a = 2092 a = 2099 a = 2106 a = 2113 a = 2120 a = 2127 a = 2134 a = 2141 a = 2148 a = 2155 a = 2162 a = 2169 a = 2176 a = 2183 a = 2190 a = 2197 a = 2204 a = 2211 a = 2218 a = 2225 a = 2232 a = 2239 a = 2246 a = 2253 a = 2260 a = 2267 a = 2274 a = 2281 a = 2288 a = 2295 a = 2302 a = 2309 a = 2316 a = 2323 a = 2330 a = 2337 a = 2344 a = 2351 a = 2358 a = 2365 a = 2372 a = 2379 a = 2386 a = 2393 a = 2400 a = 2407 a = 2414 a = 2421 a = 2428 a = 2435 a = 2442 a = 2449 a = 2456 a = 2463 a = 2470 a = 2477 a = 2484 a = 2491 a = 2498 a = 2505 a = 2512 a = 2519 a = 2526 a = 2533 a = 2540 a = 2547 a = 2554 a = 2561 a = 2568 a = 2575 a = 2582 a = 2589 a = 2596 a = 2603 a = 2610 a = 2617 a = 2624 a = 2631 a = 2638 a = 2645 a = 2652 a = 2659 a = 2666 a = 2673 a = 2680 a = 2687 a = 2694 a = 2701 a = 2708 a = 2715 a = 2722 a = 2729 a = 2736 a = 2743 a = 2750 a = 2757 a = 2764 a = 2771 a = 2778 a = 2785 a = 2792 a = 2799 a = 2806 a = 2813 a = 2820 a = 2827 a = 2834 a = 2841 a = 2848 a = 2855 a = 2862 a = 2869 a = 2876 a = 2883 a = 2890 a = 2897 a = 2904 a = 2911 a = 2918 a = 2925 a = 2932 a = 2939 a = 2946 a = 2953 a = 2960 a = 2967 a = 2974 a = 2981 a = 2988 a = 2995 a = 3002 a = 3009 a = 3016 a = 3023 a = 3030 a = 3037 a = 3044 a = 3051 a = 3058 a = 3065 a = 3072 a = 3079 a = 3086 a = 3093 a = 3100 a = 3107 a = 3114 a = 3121 a = 3128 a = 3135 a = 3142 a = 3149 a = 3156 a = 3163 a = 3170 a = 3177 a = 3184 a = 3191 a = 3198 a = 3205 a = 3212 a = 3219 a = 3226 a = 3233 a = 3240 a = 3247 a = 3254 a = 3261 a = 3268 a = 3275 a = 3282 a = 3289 a = 3296 a = 3303 a = 3310 a = 3317 a = 3324 a = 3331 a = 3338 a = 3345 a = 3352 a = 3359 a = 3366 a = 3373 a = 3380 a = 3387 a = 3394 a = 3401 a = 3408 a = 3415 a = 3422 a = 3429 a = 3436 a = 3443 a = 3450 a = 3457 a = 3464 a = 3471 a = 3478 a = 3485 a = 3492 a = 3499 a = 3506 a = 3513 a = 3520 a = 3527 a = 3534 a = 3541 a = 3548 a = 3555 a = 3562 a = 3569 a = 3576 a = 3583 a = 3590 a = 3597 a = 3604 a = 3611 a = 3618 a = 3625 a = 3632 a = 3639 a = 3646 a = 3653 a = 3660 a = 3667 a = 3674 a = 3681 a = 3688 a = 3695 a = 3702 a = 3709 a = 3716 a = 3723 a = 3730 a = 3737 a = 3744 a = 3751 a = 3758 a = 3765 a = 3772 a = 3779...