Cody

Solution 1436116

Submitted on 8 Feb 2018 by Andrew Dobrovolc
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
A = [1 2 3 4 5 6 7 8 NaN]; subsz = [1 3]; B = [2 5 (7+8)/2]; assert(norm(B-blknanavg(A,subsz)) < 1e-10)

r = 1 c = 1 c = 1 4 c = 1 4 7 C = 1 2 3 B = 2 0 0 C = 4 5 6 B = 2 5 0 t = 1 C = 7 8 B = 2.0000 5.0000 7.5000

2   Pass
A = [1 2 3 4 NaN 6 7 NaN 9].'; subsz = [3,1]; B = [2 5 8].'; assert(norm(B-blknanavg(A,subsz)) < 1e-10)

r = 1 r = 1 4 r = 1 4 7 c = 1 C = 1 2 3 B = 2 0 0 t = 1 C = 4 6 B = 2 5 0 t = 1 C = 7 9 B = 2 5 8

3   Pass
A = [1 1 1 2 NaN 2 1 NaN 1 NaN 2 NaN 3 3 3 NaN NaN 4 3 3 3 NaN 4 4]; subsz = [2 3]; B = [1 2 3 4]; assert(norm(B-blknanavg(A,subsz)) < 1e-10)

r = 1 r = 1 3 c = 1 c = 1 4 t = 1 C = 1 1 1 1 1 B = 1 0 0 0 t = 1 t = 1 t = 1 C = 2 2 2 B = 1 2 0 0 C = 3 3 3 3 3 3 B = 1 2 3 0 t = 1 t = 1 t = 1 C = 4 4 4 B = 1 2 3 4

4   Pass
A = rand(100,300); A(randperm(numel(A),10)) = NaN; subsz = size(A); B = mean(A(:),'omitnan'); assert(norm(B-blknanavg(A,subsz)) < 1e-10)

r = 1 c = 1 t = 1 t = 1 t = 1 t = 1 t = 1 t = 1 t = 1 t = 1 t = 1 t = 1 C = Columns 1 through 17 0.9405 0.3874 0.4501 0.5486 0.6648 0.3294 0.5513 0.2766 0.9978 0.1317 0.0881 0.7335 0.7431 0.0953 0.1957 0.9556 0.3895 Columns 18 through 34 0.6944 0.9562 0.0424 0.3985 0.5147 0.1563 0.7697 0.1651 0.5795 0.6399 0.3714 0.2473 0.1650 0.7056 0.9271 0.2375 0.0810 Columns 35 through 51 0.9300 0.7438 0.7997 0.3015 0.4635 0.4017 0.0430 0.9255 0.7693 0.7450 0.8830 0.6317 0.6756 0.7070 0.8507 0.1855 0.1289 Columns 52 through 68 0.5750 0.8121 0.2873 0.4272 0.7102 0.0864 0.5174 0.7239 0.3361 0.6977 0.8777 0.7510 0.9438 0.3968 0.0409 0.1762 0.7476 Columns 69 through 85 0.9136 0.6325 0.7650 0.1865 0.2591 0.4785 0.8168 0.0837 0.8661 0.6008 0.2905 0.9569 0.2318 0.4208 0.0731 0.4049 0.3216 Columns 86 through 102 0.1912 0.9492 0.7467 0.9975 0.6018 0.9023 0.7089 0.4564 0.2395 0.5503 0.4203 0.9311 0.1165 0.9674 0.2685 0.3041 0.1408 Columns 103 through 119 0.6321 0.6459 0.2863 0.2474 0.7659 0.4297 0.5393 0.1211 0.6900 0.0275 0.8113 0.2822 0.3805 0.7188 0.9517 0.3795 0.5723 Columns 120 through 136 0.0671 0.6849 0.0038 0.6177 0.4838 0.2332 0.7782 0.3530 0.5620 0.3049 0.8142 0.4844 0.5367 0.1381 0.1074 0.1838 0.6655 Columns 137 through 153 0.7865 0.9936 0.6371 0.9963 0.6154 0.7507 0.0260 0.4820 0.3636 0.5402 0.1644 0.8370 0.8502 0.3058 0.0152 0.2756 0.2162 Columns 154 through 170 0.1803 0.0420 0.3126 0.5666 0.6528 0.0736 0.6953 0.7943 0.2590 0.5766 0.9676 0.5460 0.6728 0.2304 0.4967 0.5834 0.9310 Columns 171 through 187 0.9951 0.6895 0.5037 0.3131 0.5898 0.3884 0.2371 0.8131 0.9656 0.5586 0.3157 0.1485 0.4226 0.5229 0.2251 0.5130 0.8241 Columns 188 through 204 0.4448 0.2914 0.5162 0.0516 0.2721 0.5691 0.9678 0.0632 0.0568 0.4326 0.8771 0.1641 0.5151 0.5396 0.4213 0.9125 0.9730 Columns 205 through 221 0.9008 0.8213 0.4926 0.9249 0.4932 0.8393 0.0715 0.1784 0.4449 0.7089 0.9682 0.2513 0.8086 0.5420 0.2040 0.0646 0.2765 Columns 222 through 238 0.7938 0.4355 0.2916 0.9946 0.5022 0.2874 0.4238 0.4884 0.4308 0.2357 0.2456 0.1104 0.1816 0.1886 0.4721 0.1732 0.7542 Columns 239 through 255 0.3658 0.0083 0.2156 0.7379 0.1182 0.9208 0.2395 0.9429 0.1803 0.4380 0.0321 0.3682 0.5929 0.0385 0.5837 0.3404 0.6099 Columns 256 through 272 0.8806 0.4947 0.5562 0.4747 0.2929 0.2737 0.3059 0.9025 0.9430 0.7456 0.4367 0.6216 0.9368 0.3657 0.6890 0.0405 0.8555 Columns 273 through 289 0.3137 0.9468 0.0919 0.3081 0.3176 0.9026 0.3927 0.1003 0.3044 0.4779 0.3511 0.5518 0.8077 0.4288 0.5945 0.3533 0.6618 Columns 290 through 306 0.3012 0.8559 0.5412 0.7156 0.4966 0.8587 0.8140 0.6965 0.3714 0.7303 0.8266 0.5776 0.4136 0.8223 0.3111 0.0560 0.0051 Columns 307 through 323 0.5682 0.9882 0.5345 0.2337 0.4781 0.7555 0.5905 0.3701 0.6556 0.2237 0.0382 0.7833 0.1726 0.5739 0.1039 0.7390 0.1312 Columns 324 through 340 0.7133 0.3805 0.8322 0.6317 0.1386 0.0359 0.8236 0.3417 0.5564 0.7263 0.7279 0.3796 0.9630 0.7542 0.0103 0.7611 0.0770 Columns 341 through 357 0.1924 0.9336 0.4247 0.0426 0.7778 0.4817 0.0558 0.2709 0.6344 0.0778 0.0113 0.4844 0.9156 0.2008 0.3480 0.9381 0.6776 Columns 358 through 374 0.1248 0.4453 0.4662 0.5791 0.9121 0.0137 0.6017 0.5795 0.7081 0.1607 0.6772 0.1018 0.5645 0.1365 0.0268 0.6352 0.3366 Columns 375 through 391 0.6795 0.8543 0.2435 0.9709 0.0862 0.2895 0.8172 0.9634 0.0731 0.2636 0.3888 0.1783 0.9310 0.7458 0.4430 0.8775 0.7926 Columns 392 through 408 0.8528 0.9436 0.7664 0.9864 0.4845 0.8644 0.2092 0.0579 0.0874 0.7887 0.6135 0.8565 0.6180 0.7029 0.1933 0.9865 0.6362 Columns 409 through 425 0.6556 0.4820 0.2013 0.5308 0.1811 0.4797 0.1558 0.9085 0.7785 0.6342 0.0258 0.3680 0.9519 0.2233 0.5248 0.5208 0.1921 Columns 426 through 442 0.9592 0.6850 0.8580 0.8606 0.2623 0.7257 0.8083 0.5396 0.7320 0.9880 0.8658 0.7386 0.7745 0.2730 0.1561 0.3173 0.5245 Columns 443 through 459 0.2014 0.8967 0.0229 0.8552 0.9362 0.9071 0.0057 0.6684 0.8187 0.1115 0.8173 0.9246 0.6645 0.1413 0.5586 0.6326 0.2733 Columns 460 through 476 0.6146 0.9664 0.2055 0.5358 0.7068 0.0406 0.7265 0.8619 0.2168 0.3279 0.9206 0.2778 0.9349 0.0744 0.0164 0.8126 0.7020 Columns 477 through 493 0.5076 0.0964 0.9985 0.4139 0.2382 0.4715 0.3682 0.0709 0.1657 0.0407 0.5287 0.3552 0.4755 0.5023 0.6313 0.1268 0.2002 Columns 494 through 510 0.2479 0.0035 0.9413 0.7239 0.0359 0.9930 0.6601 0.7586 0.2920 0.1965 0.7854 0.2259 0.5363 0.7090 0.2587 0.5411 0.7228 Columns 511 through 527 0.4024 0.7971 0.8811 0.4056 0.5700 0.9206 0.0720 0.4811 0.4018 0.5489 0.8366 0.5814 0.2912 0.5010 0.3954 0.5709 0.6860 Columns 528 through 544 0.7316 0.5553 0.8889 0.5495 0.7552 0.6099 0.2040 0.7637 0.9591 0.8115 0.9035 0.3086 0.3655 0.7830 0.8163 0.9565 0.5826 Columns 545 through 561 0.3369 0.9322 0.9160 0.1935 0.8017 0.6498 0.7789 0.6026 0.4980 0.7786 0.1893 0.3283 0.3337 0.0128 0.6634 0.4723 0.6378 Columns 562 through 578 0.5740 0.0168 0.5047 0.7787 0.9835 0.1767 0.8341 0.1199 0.8410 0.1287 0.3839 0.8474 0.1186 0.6298 0.3394 0.5260 0.4546 Columns 579 through 595 0.7166 0.6411 0.3332 0.5891 0.9353 0.1459 0.5073 0.3653 0.3984 0.0093 0.1904 0.5929 0.0551 0.0031 0.0921 0.0983 0.1827 Columns 596 through 612 0.8087 0.7109 0.5667 0.0663 0.6378 0.9559 0.0142 0.3032 0.4167 0.1116 0.5886 0.9408 0.5020 0.4744 0.6234 0.8711 0.2112 Columns 613 through 629 0.2250 0.5058 0.1737 0.4844 0.1587 0.1370 0.0803 0.2213 0.4758 0.8146 0.3331 0.2736 0.8988 0.3477 0.9898 0.0623 0.8652 Columns 630 through 646 0.4598 0.8574 0.1804 0.5060 0.8382 0.9648 0.9935 0.8063 0.1702 0.2698 0.9046 0.4567 0.3168 0.3118 0.7193 0.1614 0.6142 Columns 647 through 663 0.7584 0.2639 0.3319 0.9050 0.1897 0.1444 0.7107 0.4073 0.0576 0.5761 0.6565 0.0438 0.0221 0.7104 0.9452 0.4856 0.9095 Columns 664 through 680 0.1974 0.6569 0.1050 0.6795 0.1629 0.9647 0.7703 0.3374 0.7665 0.6204 0.0957 0.7816 0.9303 0.3327 0.8046 0.1504 0.0052 Columns 681 through 697 0.6453 0.5721 0.7066 0.3106 0.0828 0.2675 0.8458 0.0500 0.9412 0.1068 0.6369 0.1467 0.2873 0.7810 0.8115 0.5596 0.1526 Columns 698 through 714 0.1235 0.0001 0.8514 0.6081 0.9285 0.7895 0.1576 0.6528 0.0981 0.2543 0.8504 0.6503 0.3715 0.0938 0.3461 0.7172 0.8145 Columns 715 through 731 0.3835 0.9394 0.4969 0.3296 0.8913 0.8222 0.9906 0.7834 0.9347 0.9793 0.1193 0.7044 0.5712 0.7364 0.1173 0.0786 0.2464 Columns 732 through 748 0.1525 0.4831 0.3049 0.8448 0.1207 0.2182 0.3906 0.2450 0.8655 0.9024 0.1821 0.1813 0.6327 0.5490 0.2975 0.3496 0.3009 Columns 749 through 765 0.4568 0.9627 0.8327 0.2132 0.2168 0.2718 0.9327 0.1693 0.3946 0.3877 0.0564 0.1745 0.2196 0.0451 0.7772 0.0951 0.4795 Columns 766 through 782 0.7813 0.5404 0.3666 0.3590 0.9833 0.1590 0.0332 0.9214 0.0996 0.2732 0.3231 0.6092 0.6167 0.7946 0.8513 0.1916 0.7563 Columns 783 through 799 0.7926 0.3105 0.8012 0.9159 0.2215 0.1550 0.5357 0.7167 0.7711 0.6749 0.1301 0.5348 0.4796 0.5620 0.4345 0.3934 0.2834 Columns 800 through 816 0.0862 0.4370 0.6756 0.6576 0.9590 0.8393 0.0462 0.7901 0.7655 0.3931 0.8843 0.3404 0.8145 0.3807 0.5120 0.0851 0.2001 Columns 817 through 833 0.0849 0.0437 0.7624 0.9054 0.1635 0.8199 0.4633 0.6794 0.9173 0.2996 0.4589 0.2550 0.7910 0.7509 0.0064 0.7189 0.7737 Columns 834 through 850 0.4914 0.9201 0.5664 0.3557 0.8915 0.0848 ...

5   Pass
subsz = [4,6]; B = 10*rand(10,20); A = repelem(B,subsz(1),subsz(2)); A(randperm(numel(A),10)) = NaN; assert(norm(B-blknanavg(A,subsz)) < 1e-10)

r = 1 r = 1 5 r = 1 5 9 r = 1 5 9 13 r = 1 5 9 13 17 r = 1 5 9 13 17 21 r = 1 5 9 13 17 21 25 r = 1 5 9 13 17 21 25 29 r = 1 5 9 13 17 21 25 29 33 r = 1 5 9 13 17 21 25 29 33 37 c = 1 c = 1 7 c = 1 7 13 c = 1 7 13 19 c = 1 7 13 19 25 c = 1 7 13 19 25 31 c = 1 7 13 19 25 31 37 c = 1 7 13 19 25 31 37 43 c = 1 7 13 19 25 31 37 43 49 c = 1 7 13 19 25 31 37 43 49 55 c = 1 7 13 19 25 31 37 43 49 55 61 c = 1 7 13 19 25 31 37 43 49 55 61 67 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 79 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 109 c = 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 109 115 C = Columns 1 through 17 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 Columns 18 through 24 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 7.1932 B = Columns 1 through 17 7.1932 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 18 through 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C = Columns 1 through 17 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 Columns 18 through 24 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 7.6756 B = Columns 1 through 17 7.1932 7.6756 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 18 through 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C = Columns 1 through 17 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 Columns 18 through 24 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 2.9635 B = Columns 1 through 17 7.1932 7.6756 2.9635 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 18 through 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C = Columns 1 through 17 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 Columns 18 through 24 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 3.2440 B = Columns 1 through 17 7.1932 7.6756 2.9635 3.2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...