Cody

# Problem 824. Set the array elements whose value is 13 to 0

Solution 3255538

Submitted on 17 Oct 2020 by MtF
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')

A = 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')

A = 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')

A = []

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')

A = 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')

A(:,:,1) = 0.1212 0.4854 0.0010 0.9497 0.3726 0.8833 0.4154 0.2804 0.4696 0.2421 0.3728 0.4585 0.8271 0.6975 0.8513 0.4591 0.9911 0.5106 0.8565 0.1932 0.2665 0.8290 0.6602 0 0.8607 0.9410 0.4833 0.4552 0.2494 0.5128 0.2511 0.3495 0.7997 0.1098 0.1937 0.5765 0.3323 0.9089 0.5421 0.9008 0.3787 0.7424 0.2411 0.9640 0.3399 0.8076 0.3951 0.0590 0.5492 0.3643 0.1136 0.3203 0.2656 0.5132 0.6085 0.2743 0.5976 0.2179 0.4946 0.0212 0.1489 0.0471 0.9119 0.4352 0.0498 0.3696 0.4828 0.8838 0.1959 0.5712 0.7778 0.1957 0.3660 0.7554 0.3540 0.6769 0.3461 0.0515 0.5960 0.7945 0.1137 0.5489 0.3190 0.1393 0.2506 0.8137 0.0280 0.5701 0.8837 0.4490 0.8088 0.3734 0.7295 0.6043 0.4982 0.6893 0.5237 0.5931 0.9314 0.2150 A(:,:,2) = 0.1803 0 0.8713 0.6609 0.4422 0.1061 0.9904 0.7146 0.8132 0.6416 0.3670 0.1450 0.6086 0.2638 0.4071 0.4724 0.2414 0.2136 0.3489 0.2217 0.0086 0.3342 0.2862 0.5735 0.1909 0.3996 0.6573 0.8613 0.1853 0.4278 0.6894 0.2190 0.6641 0.0207 0.7716 0.6086 0.6313 0.7882 0.1150 0.9734 0.9805 0.8254 0.4333 0.0417 0.2618 0.2873 0.2401 0.1905 0.7856 0.6078 0.5798 0.8574 0.1734 0.2987 0.6499 0.9608 0.4487 0.9298 0.7669 0.8407 0.2969 0.9045 0.1734 0.8333 0.0930 0.4489 0.1319 0.4351 0.5661 0.1669 0.7670 0.9375 0.0446 0.4954 0.5371 0.5387 0.2681 0.7450 0.5113 0.3198 0.6204 0.5340 0.7918 0.3765 0.6772 0.7857 0.7015 0.6583 0.9551 0.1733 0.1230 0.5382 0.1049 0.3768 0.6160 0.9046 0.9318 0.7725 0.5526 0.1736 A(:,:,3) = 0.4749 0.7156 0.1924 0.6411 0.1688 0.9290 0.1460 0.1812 0.2296 0.4968 0.4216 0.9606 0.0101 0.7784 0.1278 0.6539 0.8474 0.0369 0.4252 0.0729 0.6356 0.3860 0.2494 0.4229 0.8226 0.7808 0.1552 0.4317 0.6194 0.6243 0.4768 0.6928 0.8005 0.5844 0.8640 0.4631 0.3028 0.2998 0.9044 0.7469 0.2372 0.4046 0.7223 0.2935 0.7974 0 0.0958 0.5175 0.6858 0.6486 0.9635 0.0743 0.9695 0.1636 0.1690 0.6305 0.0313 0.3895 0.7668 0.6962 0.4101 0.6862 0.0784 0.3955 0.9121 0.4445 0.5103 0.3104 0.0078 0.4675 0.9575 0.1601 0.8302 0.1545 0.9114 0.5087 0.4971 0.4867 0.6254 0.2957 0.9681 0.6919 0.6672 0.8497 0.3733 0.0245 0.6368 0.0044 0.2505 0.8391 0.8124 0.5561 0.7298 0.6108 0.8727 0.3346 0.9330 0.3447 0.7130 0.8886 A(:,:,4) = 0.5458 0.6047 0.1157 0.0448 0.7957 0.8573 0.5485 0.6175 0.0700 0.7194 0.8866 0.4964 0.4472 0.2814 0.3050 0.3452 0.0967 0.5199 0.9339 0.7025 0.3527 0.5907 0.8901 0.7041 0.6591 0.8569 0.4243 0.8872 0.3324 0.1119 0.7419 0.6856 0.3875 0.6024 0.4194 0.8221 0.9389 0.8610 0.9859 0.5335 0.1309 0.3539 0.3816 0.1502 0.8402 0.7989 0.8921 0.1442 0.4926 0.1924 0.4447 0.7616 0.8196 0.6000 0.5392 0.9304 0.4494 0.9938 0.2389 0.8421 0.2313 0.7243 0.0797 0.3837 0.9349 0.0697 0.5848 0.4956 0.2156 0.5144 0.5149 0.9701 0.7447 0.2180 0.6890 0.8003 0.3462 0.2168 0.2042 0.9424 0.7022 0.2719 0.9860 0.5429 0.7348 0.9106 0.9476 0.3284 0.7832 0.4909 0.3605 0.9027 0.8645 0.3417 0.7714 0.4766 0.6701 0.0601 0.5705 0.3923 A(:,:,5) = 0.2858 0.0196 0.2099 0.1349 0.5468 0.3774 0.0135 0.0582 0.0192 0.5240 0.4368 0.5674 0.9119 0.1535 0.2996 0.2005 0.0184 0.0824 0.6746 0.6193 0.9024 0.3425 0.2066 0.0542 0.2915 0.8359 0.9186 0.6369 0.5547 0.7283 0.0394 0.9481 0.6884 0.4561 0.3943 0.6054 0.0244 0.2450 0.9353 0.8608 0.1059 0.8757 0.4780 0.9433 0.9766 0.3781 0.2488 0.9079 0.7187 0.7709 0.2101 0.1378 0.0029 0.5937 0.1491 0.2644 0.0499 0.6848 0.7092 0.9674 0.6028 0.8869 0.8003 0.2878 0.8361 0.4154 0.5385 0.5095 0.0507 0.1586 0.1093 0.8318 0.6557 0.3396 0.8217 0.5787 0.7931 0.7650 0.3448 0.6381 0.0412 0.4680 0.0843 0.0302 0.3830 0.2018 0.1984 0.2174 0.1315 0.9256 0.1670 0.5406 0.5601 0.8076 0.5498 0.3416 0.2817 0.1523 0.9794 0.6624 A(:,:,6) = 0.9572 0.7685 0.0287 0.5129 0.1674 0.7204 0.5510 0.2464 0.2605 0.2801 0.5561 0.9607 0.8029 0.8957 0.1897 0.8589 0.2005 0.9431 0.2944 0.3652 0.9936 0.9892 0.0531 0.9266 0.1082 0.6468 0.0751 0.5214 0.5515 0.8723 0.2737 0.9629 0.7137 0.2239 0.1575 0.5573 0.7650 0.4084 0.8432 0.3612 0.4791 0.6672 0.9925 0.1071 0.3456 0.7071 0.4400 0.2732 0.3461 0.6960 0.5210 0.2804 0.5163 0.9563 0.2977 0.5921 0.6373 0.0874 0.0725 0.7820 0.8953 0.6338 0.6275 0.1798 0.2207 0.8074 0.1982 0.7629 0.3614 0.0927 0.9896 0.2538 0.1923 0.1329 0.0879 0.1962 0.8812 0.4064 0.4169 0.0014 0.3560 0.0921 0.8252 0.3865 0.4583 0.7361 0.8359 0.9932 0.8255 0.5255 0.8021 0.4897 0.8320 0.3436 0.7650 0.8913 0.9538 0.4362 0.9020 0.3613 A(:,:,7) = 0.4961 0.9719 0.0303 0.2677 0.1684 0.2553 0.4155 0.0675 0.7492 0.4579 0.1163 0.6744 0.4743 0.8966 0.8628 0.0250 0.9222 0.3614 0.5496 0.4359 0.7205 0.6934 0.6119 0.7967 0.6580 0.6374 0.7891 0.3479 0.7125 0.3711 0.5547 0.8051 0.5052 0.8925 0.2854 0.8116 0.3148 0.3459 0.1573 0.7376 0.9183 0.3213 0.3613 0.8087 0.4343 0.1544 0.1346 0.0487 0.8299 0.4244 0.1731 0.5120 0.9131 0.7134 0.7632 0.0511 0.0431 0.7395 0.4623 0.1322 0.3070 0.6823 0.5787 0.7138 0.3280 0.6889 0.6342 0.0484 0.5307 0.5703 0.1610 0.4947 0.9011 0.1932 0.7220 0.5867 0.8538 0.5063 0.0637 0.4519 0.5233 0.5198 0.6945 0.3617 0.4513 0.4842 0.4946 0.4943 0.0018 0.1553 0.6267 0.3188 0.0948 0.4022 0.0062 0.9614 0.2123 0.0932 0.6301 0.0170 A(:,:,8) = 0.0700 0.8405 0.6418 0.0441 0.0260 0.9668 0.5092 0.5413 0.9672 0.3880 0.3286 0.3893 0.8414 0.9042 0.0298 0.8587 0.1514 0.0029 0.2038 0.6680 0.9504 0.9352 0.2213 0.6398 0.5462 0.2256 0.0233 0.4218 0.8982 0.2487 0.8458 0.4241 0.0126 0.5020 0.2834 0.1184 0.2217 0.6630 0.4257 0.5064 0.4758 0.9783 0.8919 0.3373 0.4204 0.3464 0.2612 0.2340 0.9478 0.3140 0.0543 0.9512 0.3593 0.1975 0.9948 0.9031 0.0925 0.3922 0.9116 0.7801 0.5291 0.4273 0.8417 0.9180 0.7490 0.5775 0.1843 0.7277 0.3987 0.1945 0.8099 0.7890 0.5859 0.5726 0.3977 0.1260 0.5256 0.9438 0.1024 0.9490 0.5047 0.0686 0.7642 0.7812 0.7241 0.0423 0.9998 0.4976 0.2977 0.0911 0.6204 0.0226 0.3641 0.8232 0.8999 0.0271 0.3598 0.2225 0.0841 0.8292 A(:,:,9) = 0.6083 0.0547 0.8126 0.9367 0.8325 0.1938 0.4164 0.0887 0.3777 0.3965 0.6173 0.9643 0.9939 0.9958 0.2897 0.1704 0.9727 0.1766 0.6175 0.8161 0.4697 0.8921 0.9673 0.4217 0.7635 0.4174 0.8072 0.6325 0.3302 0.4236 0.7977 0.0975 0.1333 0.9152 0.3724 0.9438 0.2925 0.1096 0.4561 0.5498 0.0504 0.2620 0.4775 0.2869 0.0972 0.9416 0.4158 0.4457 0.9141 0.0530 0.1942 0.2501 0.5373 0.9049 0.5361 0.3683 0.2449 0.7794 0.7935 0.4180 0.8338 0.3832 0.1278 0.9427 0.5156 0.2897 0.5205 0.1020 0.5518 0.4555 0.2367 0.8139 0.7279 0.7895 0.9388 0.0186 0.3396 0.5336 0.4965 0.0222 0.5449 0.5447 0.3288 0.4148 0.1786 0.0843 0.1299 0.2611 0.2663 0.1999 0.6187 0.0313 0.0371 0.5311 0.8712 0.7567 0.5901 0.9928 0.6903 0.4917 A(:,:,10) = 0.9711 0.3519 0.8145 0.5863 0.1887 0.6963 0.1907 0.2046 0.1931 0.4896 0.3926 0.8247 0.4461 0.1393 0.4715 0.9464 0.1907 0.7943 0.4954 0.2501 0.1919 0.2610 0.0280 0.3182 0.9569 0.4931 0.1502 0.9786 0.2240 0.6627 0.5782 0.2051 0.6513 0.1056 0.8625 0.4371 0.9676 0.1763 0.6865 0.0667 0.9846 0.6107 0.9577 0.7000 0.8694 0.6227 0.3077 0.0586 0.7653 0.5875 0.4753 0.4052 0.4959 0.5882 0.5971 0.0573 0.1413 0.9966 0.3535 0.2547 0.7249 0.7568 0.5942 0.9097 0.0189 0.2366 0.5991 0.7896 0.9632 0.8706 0.0088 0.8887 0.0407 0.2742 0.5449 0.8806 ...

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')

A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 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 A = 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))

A = 13.3000

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!