Cody

Solution 2021849

Submitted on 14 Nov 2019 at 20:54 by Romain Demory
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 = [15 13 3]; y_correct = [15 0 3]; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 15 0 3

2   Pass
A = 13; y_correct = 0; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 0

3   Pass
A = []; y_correct = []; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = []

4   Pass
A = [13 0 13; 13 13 8; 13 25 2]; titi = [0 0 0 ; 0 0 8;0 25 2]; assert(isequal(your_fcn_name(A),titi)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 0 0 0 0 0 8 0 25 2

5   Pass
A=rand(10,10,10); A(1,2,2)=13; A(3,4,1)=13; A(5,6,3)=13; % what you cannot do but me I can ;) ! titi = A; I=find(titi==13); [u,v,w]=ind2sub(size(titi),I); for ii = 1 : numel(u) titi(u(ii),v(ii),w(ii))=0; end assert(isequal(your_fcn_name(A),titi)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B(:,:,1) = 0.2408 0.3525 0.7591 0.8883 0.2807 0.6694 0.8477 0.9769 0.8981 0.1896 0.6381 0.3285 0.9788 0.4444 0.9208 0.2067 0.2805 0.0122 0.2677 0.7062 0.9599 0.7238 0.2573 0 0.8038 0.9281 0.0634 0.9776 0.8106 0.9269 0.8799 0.4511 0.8793 0.1224 0.3211 0.1824 0.5904 0.2756 0.7522 0.4423 0.3884 0.5178 0.4816 0.3695 0.7725 0.7609 0.9509 0.7456 0.9165 0.5429 0.7134 0.1104 0.3390 0.3538 0.6590 0.4703 0.2978 0.7776 0.7166 0.6817 0.6325 0.9599 0.3443 0.3504 0.3053 0.5173 0.0188 0.1098 0.4813 0.1145 0.6176 0.4571 0.3812 0.5460 0.1626 0.5424 0.9637 0.6640 0.3674 0.4841 0.5966 0.3538 0.7073 0.2045 0.4207 0.8697 0.5046 0.8806 0.1070 0.4649 0.8370 0.0376 0.2566 0.1206 0.1507 0.1311 0.0876 0.5857 0.5546 0.5994 B(:,:,2) = 0.8699 0 0.8206 0.5155 0.5350 0.4381 0.4023 0.6815 0.0020 0.7014 0.0122 0.9879 0.0350 0.0133 0.5719 0.9074 0.0074 0.2554 0.2842 0.1803 0.7747 0.1170 0.7123 0.0518 0.9757 0.5571 0.8023 0.1000 0.7064 0.1191 0.9273 0.8700 0.2795 0.8940 0.0002 0.9308 0.5960 0.5714 0.1282 0.5502 0.6474 0.1632 0.7870 0.0212 0.9146 0.2989 0.6184 0.3564 0.2322 0.0472 0.9398 0.7572 0.3297 0.7861 0.7169 0.8043 0.2649 0.4334 0.3888 0.3530 0.8804 0.4617 0.7852 0.3004 0.0254 0.7878 0.1963 0.9036 0.3838 0.1682 0.0201 0.5326 0.3789 0.4299 0.3701 0.8733 0.7199 0.3827 0.9843 0.5188 0.9463 0.8810 0.1906 0.5733 0.5961 0.5095 0.0768 0.8600 0.1025 0.9540 0.2105 0.9980 0.6912 0.2643 0.2945 0.8209 0.4160 0.3488 0.6649 0.9101 B(:,:,3) = 0.3324 0.0514 0.2744 0.4586 0.0758 0.4186 0.8734 0.8034 0.9355 0.5894 0.6845 0.8430 0.9938 0.1622 0.3318 0.6474 0.4221 0.8878 0.8126 0.5110 0.1227 0.7311 0.7578 0.9475 0.8308 0.1672 0.7680 0.4229 0.4295 0.5391 0.3548 0.3182 0.2596 0.6167 0.9002 0.0515 0.9394 0.5007 0.1887 0.4085 0.6609 0.3616 0.1736 0.5880 0.9830 0 0.6252 0.0328 0.3525 0.4809 0.8242 0.9605 0.2153 0.0206 0.2714 0.3672 0.7605 0.3414 0.1213 0.6973 0.0518 0.1117 0.8675 0.0821 0.1402 0.6543 0.9606 0.8005 0.8139 0.6051 0.6166 0.4141 0.0257 0.1807 0.5990 0.8705 0.3697 0.7314 0.2372 0.2344 0.8032 0.7127 0.8011 0.7027 0.9735 0.5963 0.1036 0.5806 0.7588 0.7401 0.7082 0.5975 0.0216 0.2160 0.9890 0.1636 0.7580 0.0370 0.3086 0.0897 B(:,:,4) = 0.5769 0.8133 0.0292 0.4336 0.4133 0.3901 0.4850 0.7105 0.1551 0.6472 0.3037 0.6345 0.4873 0.0035 0.8956 0.9090 0.3340 0.0657 0.3537 0.1304 0.9964 0.9534 0.7162 0.4030 0.6375 0.8849 0.3301 0.4084 0.7304 0.5770 0.3162 0.5634 0.5153 0.1749 0.3833 0.6078 0.0575 0.1172 0.1743 0.5011 0.1119 0.9152 0.8212 0.9169 0.8419 0.7620 0.6323 0.7093 0.0554 0.5188 0.5971 0.1683 0.0380 0.3261 0.3082 0.9831 0.5160 0.5653 0.8795 0.3464 0.1274 0.4882 0.3623 0.4044 0.5830 0.3798 0.6618 0.0192 0.4036 0.2559 0.6480 0.4913 0.4472 0.5471 0.0171 0.0825 0.2853 0.6643 0.8302 0.4591 0.8436 0.8668 0.5708 0.1055 0.9179 0.2115 0.8817 0.5254 0.1951 0.9550 0.9488 0.5287 0.8956 0.7905 0.5072 0.3958 0.9117 0.1760 0.9772 0.2444 B(:,:,5) = 0.9126 0.6714 0.9058 0.8688 0.8636 0.4647 0.4635 0.5293 0.4973 0.9394 0.8593 0.8091 0.0887 0.0668 0.6927 0.9901 0.9872 0.7287 0.8612 0.5047 0.3078 0.2901 0.9920 0.8013 0.0868 0.2611 0.8102 0.8568 0.1603 0.7977 0.7230 0.4470 0.7450 0.6182 0.9503 0.4533 0.1212 0.9736 0.0823 0.1007 0.3242 0.5698 0.1999 0.7914 0.3970 0.5471 0.1526 0.5320 0.5573 0.7475 0.8435 0.1230 0.9826 0.9904 0.9030 0.0158 0.2661 0.3786 0.9278 0.3649 0.6348 0.5420 0.9042 0.7156 0.5895 0.9342 0.9878 0.7178 0.5459 0.9407 0.8626 0.2936 0.3261 0.6189 0.8408 0.5636 0.3932 0.5342 0.7343 0.9738 0.8421 0.0058 0.4010 0.6492 0.0628 0.8287 0.6555 0.1067 0.3583 0.7601 0.0267 0.8308 0.3855 0.9396 0.6856 0.2472 0.2922 0.5680 0.7512 0.0571 B(:,:,6) = 0.0360 0.3613 0.3387 0.2112 0.4024 0.7025 0.5366 0.2737 0.7847 0.1492 0.4018 0.1370 0.7546 0.6094 0.0976 0.7872 0.5174 0.3376 0.1886 0.2829 0.9677 0.9189 0.1848 0.3014 0.0588 0.4179 0.5856 0.8107 0.9924 0.6686 0.7876 0.5879 0.2263 0.3917 0.8339 0.4616 0.4692 0.1563 0.8233 0.8812 0.1883 0.9805 0.6123 0.0753 0.2780 0.5723 0.4393 0.9850 0.0636 0.7449 0.5249 0.4177 0.2711 0.6228 0.0552 0.6812 0.1080 0.0844 0.0760 0.5562 0.0179 0.8867 0.1612 0.3589 0.9032 0.3176 0.4221 0.8985 0.4076 0.3418 0.7921 0.9315 0.4202 0.1086 0.7067 0.8457 0.2923 0.7527 0.7368 0.1601 0.4506 0.9761 0.2650 0.6949 0.9429 0.3552 0.4962 0.7820 0.3530 0.1530 0.1213 0.2500 0.0080 0.8552 0.1386 0.9709 0.9241 0.4016 0.3733 0.1585 B(:,:,7) = 0.6863 0.1753 0.0718 0.3780 0.1523 0.3547 0.4512 0.4855 0.0408 0.5212 0.6094 0.1710 0.2682 0.9593 0.4551 0.8580 0.1099 0.7026 0.4534 0.3109 0.7444 0.0322 0.8714 0.1705 0.5881 0.1173 0.1547 0.6527 0.0475 0.6938 0.7961 0.2590 0.1667 0.3671 0.2536 0.7564 0.4883 0.7524 0.2025 0.6236 0.7824 0.3547 0.4195 0.5950 0.7894 0.8205 0.3781 0.7998 0.9125 0.2250 0.6384 0.6735 0.1004 0.2805 0.3290 0.3123 0.8159 0.2775 0.8853 0.2232 0.7050 0.5809 0.6560 0.2154 0.8735 0.5906 0.5017 0.0371 0.0116 0.5032 0.9299 0.8234 0.1663 0.8224 0.7876 0.8319 0.1335 0.2744 0.1282 0.5144 0.1875 0.3208 0.2678 0.2184 0.9505 0.8697 0.1244 0.1193 0.0890 0.1962 0.9039 0.3977 0.5045 0.6141 0.5434 0.5527 0.8025 0.6106 0.8696 0.2515 B(:,:,8) = 0.3281 0.6164 0.7522 0.8594 0.7585 0.2617 0.0130 0.4894 0.3303 0.5874 0.8378 0.6047 0.5087 0.7821 0.6540 0.2877 0.8642 0.9026 0.5686 0.9638 0.3626 0.1665 0.8279 0.7941 0.6181 0.1168 0.7980 0.3963 0.8993 0.0928 0.8628 0.2311 0.6765 0.9441 0.2506 0.3453 0.9442 0.9464 0.8803 0.7795 0.7103 0.4402 0.8826 0.5981 0.2841 0.2530 0.3861 0.1551 0.7097 0.9882 0.9561 0.3851 0.7447 0.7331 0.8671 0.7507 0.6852 0.5039 0.4533 0.6618 0.0006 0.1447 0.7359 0.0893 0.5404 0.0180 0.2983 0.9975 0.6638 0.6890 0.6514 0.9918 0.5562 0.8577 0.7040 0.1061 0.8716 0.0484 0.7770 0.6125 0.6898 0.6902 0.6674 0.7920 0.4455 0.8596 0.9627 0.5621 0.4064 0.7277 0.1436 0.2657 0.6436 0.7479 0.7223 0.2762 0.4850 0.4065 0.4495 0.5599 B(:,:,9) = 0.9301 0.5741 0.5789 0.2506 0.0334 0.9505 0.8979 0.8186 0.6019 0.7940 0.0574 0.5054 0.8857 0.6018 0.2298 0.5486 0.9357 0.2527 0.4315 0.2550 0.1592 0.9537 0.0428 0.8129 0.9951 0.3312 0.5918 0.8272 0.8836 0.5001 0.5729 0.4612 0.4110 0.5044 0.9594 0.1678 0.6850 0.2685 0.8111 0.1782 0.6778 0.8751 0.3197 0.2945 0.3575 0.5510 0.8922 0.0242 0.6030 0.6562 0.5508 0.4212 0.5665 0.1018 0.4866 0.2057 0.4400 0.0875 0.7063 0.5939 0.9578 0.6155 0.4275 0.2830 0.4314 0.4115 0.9623 0.6915 0.6169 0.5642 0.4343 0.7108 0.7749 0.7283 0.1785 0.5454 0.3240 0.8174 0.1815 0.8526 0.1537 0.2610 0.5927 0.8917 0.6421 0.3935 0.4755 0.1502 0.6372 0.8940 0.4392 0.2022 0.3583 0.2401 0.2919 0.8552 0.8382 0.2978 0.4489 0.4977 B(:,:,10) = 0.1673 0.1260 0.0669 0.3975 0.4881 0.1393 0.0708 0.8371 0.7147 0.7122 0.0050 0.4750 0.3187 0.0420 0.4427 0.0630 0.5830 0.9988 0.6923 0.1214 0.4321 0.1073 0.4594 0.5563 0.0562 0.0454 0.4220 0.4050 0.1265 0.0021 0.8087 0.6608 0.7950 0.1826 0.5386 0.2628 0.4065 0.1077 0.0555 0.9295 0.4201 0.9180 0.8284 0.6681 0.4985 0.6394 0.5705 0.7545 0.8571 0.7993 0.7850 0.8302 0.5166 0.9265 0.7539 0.8841 0.9804 0.4662 0.6883 0.8081 0.8631 0.7371 0.1825 0.5304 0.7412 0.3842 0.3552 0.5452 0.6100 0.1341 0.8200 0.6951 0.5568 0.2816 0.0462 0.5874 ...

6   Pass
A = repmat(13,89,17); assert(isequal(your_fcn_name(A),repmat(0,89,17))) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

7   Pass
A= magic(5); B =A; B(3,3) = 0 assert(isequal(your_fcn_name(A),B)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 17 24 1 8 15 23 5 7 14 16 4 6 0 20 22 10 12 19 21 3 11 18 25 2 9 B = 17 24 1 8 15 23 5 7 14 16 4 6 0 20 22 10 12 19 21 3 11 18 25 2 9

8   Pass
A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

B = 13.3000

Suggested Problems

More from this Author30