Cody

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

Solution 1261588

Submitted on 4 Sep 2017 by grey tomato
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 13 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 = 13

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 = 13 0 13 13 13 8 13 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.0535 0.8234 0.5892 0.0427 0.4151 0.7380 0.3406 0.9159 0.4231 0.4654 0.6858 0.3899 0.8988 0.3969 0.2176 0.5880 0.7556 0.5751 0.7911 0.1168 0.2349 0.0372 0.3824 13.0000 0.5141 0.1530 0.2457 0.1779 0.6207 0.0290 0.0888 0.2209 0.0486 0.4232 0.5502 0.0758 0.8662 0.1917 0.8711 0.4176 0.9798 0.8615 0.7734 0.7081 0.5143 0.6746 0.7931 0.1838 0.2923 0.6671 0.7353 0.4101 0.1125 0.8753 0.9275 0.7178 0.7821 0.1681 0.7870 0.0489 0.4481 0.6766 0.2596 0.0380 0.9527 0.5087 0.4507 0.4476 0.5397 0.3004 0.2174 0.2217 0.5743 0.6471 0.6755 0.9763 0.2409 0.0539 0.4007 0.9054 0.4152 0.3118 0.7885 0.1317 0.3516 0.6245 0.7525 0.4385 0.7042 0.9005 0.0524 0.8818 0.2750 0.5087 0.5740 0.8677 0.5922 0.2996 0.2241 0.3928 B(:,:,2) = 0.4863 13.0000 0.0311 0.9452 0.5116 0.9722 0.8253 0.8327 0.7584 0.7805 0.1388 0.1859 0.3889 0.7808 0.2816 0.7270 0.3667 0.6414 0.5211 0.6196 0.4830 0.9420 0.1198 0.7245 0.3915 0.1657 0.7789 0.6657 0.0352 0.5499 0.3335 0.0202 0.1033 0.6022 0.7505 0.0214 0.1638 0.6618 0.0166 0.4360 0.4348 0.8360 0.8857 0.0020 0.9415 0.3940 0.4577 0.1993 0.2477 0.6666 0.7000 0.6876 0.0126 0.7003 0.7274 0.4030 0.7590 0.0028 0.0668 0.0445 0.6402 0.3088 0.1504 0.5025 0.4715 0.7241 0.8408 0.6373 0.0036 0.0378 0.4365 0.9859 0.0266 0.2363 0.3501 0.1689 0.3356 0.2676 0.1148 0.4496 0.6504 0.7803 0.5458 0.7662 0.8631 0.4536 0.4603 0.6510 0.6596 0.2342 0.5256 0.9499 0.0958 0.9063 0.6898 0.3596 0.3771 0.3663 0.5992 0.2886 B(:,:,3) = 0.0245 0.3321 0.4924 0.6118 0.6035 0.7943 0.1312 0.7074 0.5422 0.5167 0.0237 0.1309 0.8230 0.8409 0.1838 0.5762 0.8657 0.0159 0.7978 0.4773 0.2639 0.7548 0.3340 0.1338 0.3434 0.1711 0.9655 0.6627 0.4270 0.4288 0.1729 0.7816 0.7007 0.5766 0.1076 0.7135 0.8754 0.7710 0.8153 0.9113 0.8935 0.7014 0.2539 0.3759 0.5459 13.0000 0.3680 0.7414 0.2594 0.6912 0.4529 0.5716 0.7537 0.0358 0.7019 0.9641 0.4020 0.7137 0.7575 0.5151 0.9399 0.1068 0.8731 0.2557 0.6701 0.4623 0.3084 0.0676 0.6419 0.8214 0.3181 0.9318 0.7124 0.5314 0.5004 0.4579 0.2071 0.9071 0.8842 0.6691 0.5416 0.3008 0.4102 0.9541 0.5208 0.2963 0.4660 0.9941 0.7382 0.8442 0.3737 0.6351 0.9963 0.2610 0.8117 0.7460 0.3255 0.7688 0.8338 0.5330 B(:,:,4) = 0.4429 0.3825 0.5022 0.1060 0.4543 0.1188 0.6213 0.0413 0.2069 0.6582 0.3832 0.3324 0.8282 0.0081 0.5790 0.4159 0.0739 0.2177 0.2435 0.9166 0.2574 0.1732 0.6541 0.5414 0.2758 0.4868 0.3867 0.5612 0.4642 0.7992 0.2187 0.4880 0.4886 0.8223 0.5255 0.4668 0.4619 0.0886 0.0693 0.1561 0.8365 0.8118 0.3641 0.5898 0.1560 0.0376 0.5947 0.5054 0.2835 0.1583 0.3988 0.0105 0.2156 0.9955 0.2374 0.2547 0.3460 0.1124 0.8104 0.6515 0.3202 0.8862 0.2601 0.3580 0.8540 0.4573 0.8101 0.7923 0.2446 0.6228 0.8967 0.1582 0.9123 0.9392 0.7557 0.3817 0.6412 0.9245 0.0264 0.0697 0.7142 0.8602 0.2742 0.1565 0.9722 0.0783 0.8724 0.6170 0.8190 0.5454 0.7211 0.8184 0.2978 0.7707 0.2502 0.4565 0.6046 0.0380 0.7841 0.7067 B(:,:,5) = 0.2352 0.1179 0.6973 0.3209 0.7719 0.3057 0.3001 0.3427 0.4358 0.1943 0.5532 0.3973 0.0885 0.0259 0.3265 0.6175 0.6844 0.2589 0.3911 0.2631 0.5351 0.4925 0.0814 0.6129 0.9097 0.2739 0.8140 0.8122 0.5140 0.9485 0.5574 0.8379 0.9463 0.9500 0.0993 0.9775 0.0587 0.3984 0.1836 0.1700 0.2595 0.0219 0.6490 0.9557 0.0511 0.1488 0.2409 0.8392 0.4905 0.1021 0.3893 0.3836 0.7543 0.3736 0.5531 0.8105 0.2221 0.5893 0.1334 0.9050 0.5687 0.9353 0.9113 0.2315 0.8853 0.5143 0.3127 0.8352 0.6966 0.0916 0.2747 0.7893 0.5143 0.4106 0.9105 0.2186 0.8084 0.8373 0.9180 0.5002 0.2549 0.2981 0.0706 0.2207 0.7765 0.5593 0.5354 0.3187 0.3930 0.6266 0.3399 0.4111 0.0566 0.1070 0.3446 0.5671 0.9883 0.5395 0.6460 0.0121 B(:,:,6) = 0.3194 0.2378 0.1446 0.5895 0.7271 0.1370 0.4049 0.1433 0.0306 0.8034 0.7219 0.3740 0.5953 0.1521 0.4711 0.6109 0.9948 0.4772 0.7641 0.8504 0.1687 0.5793 0.7788 0.4374 0.9216 0.0515 0.5485 0.5202 0.0262 0.5066 0.4937 0.3195 0.7497 0.6111 0.9846 0.5204 0.9896 0.6608 0.5071 0.4611 0.7853 0.0354 0.1778 0.5864 0.8790 0.8250 0.3225 0.6466 0.4658 0.6749 0.1062 0.4856 0.1601 0.8138 0.4033 0.1624 0.1385 0.7933 0.9303 0.2204 0.6298 0.4588 0.8323 0.4310 0.8427 0.7195 0.9626 0.6789 0.4530 0.4383 0.8428 0.8577 0.7291 0.6808 0.6419 0.4545 0.5380 0.5638 0.4901 0.6221 0.3186 0.5724 0.4086 0.5418 0.6810 0.0163 0.0421 0.8097 0.6425 0.4126 0.7741 0.7294 0.9019 0.4787 0.4522 0.5724 0.1593 0.9660 0.7285 0.4975 B(:,:,7) = 0.5766 0.9952 0.1701 0.6835 0.0709 0.0058 0.1565 0.2810 0.0958 0.5749 0.4404 0.6412 0.2787 0.5253 0.8793 0.5458 0.4972 0.4770 0.9457 0.1563 0.4279 0.6997 0.8999 0.9119 0.0046 0.4825 0.2364 0.4504 0.6393 0.4911 0.3972 0.2963 0.7613 0.5014 0.0328 0.8251 0.5356 0.3467 0.7894 0.8565 0.1124 0.1174 0.3927 0.8240 0.8481 0.4313 0.6047 0.9129 0.5296 0.1960 0.0389 0.1599 0.8818 0.6999 0.9619 0.3647 0.8890 0.0534 0.0085 0.6902 0.8779 0.8085 0.5511 0.3093 0.0604 0.9699 0.8886 0.3308 0.1399 0.7750 0.0868 0.5081 0.0372 0.6995 0.6653 0.3797 0.8793 0.3190 0.1987 0.6723 0.2743 0.8190 0.8660 0.3013 0.6516 0.2891 0.7905 0.8648 0.8948 0.9719 0.2920 0.8635 0.2935 0.6991 0.0750 0.0939 0.5983 0.9267 0.7158 0.5211 B(:,:,8) = 0.2359 0.6568 0.7899 0.6891 0.2056 0.1242 0.6870 0.0547 0.2687 0.5866 0.1816 0.0530 0.1800 0.9847 0.5975 0.1866 0.0029 0.9025 0.1948 0.5799 0.7281 0.3798 0.1022 0.5854 0.9293 0.5498 0.9985 0.6369 0.8874 0.2565 0.6196 0.0269 0.1804 0.9047 0.8629 0.8371 0.2061 0.5481 0.4657 0.9489 0.6812 0.0964 0.8793 0.5045 0.1569 0.1337 0.3271 0.3079 0.6523 0.6203 0.7325 0.3106 0.8915 0.0121 0.6093 0.4742 0.0722 0.7906 0.4990 0.2546 0.5522 0.9638 0.0228 0.1901 0.8873 0.2656 0.3836 0.5772 0.0353 0.8208 0.5535 0.1020 0.9657 0.8953 0.8862 0.4793 0.9276 0.0192 0.6941 0.2665 0.2768 0.5907 0.8592 0.3933 0.7975 0.8071 0.9043 0.8244 0.4279 0.5761 0.6377 0.3852 0.6822 0.5841 0.6045 0.2367 0.4342 0.4601 0.9739 0.8323 B(:,:,9) = 0.5161 0.5647 0.4758 0.3334 0.9221 0.0834 0.6987 0.4742 0.0626 0.1105 0.9366 0.0180 0.1316 0.6321 0.3943 0.0224 0.6933 0.8466 0.5741 0.5541 0.9711 0.9436 0.9913 0.4664 0.4313 0.4000 0.9910 0.9345 0.0577 0.3648 0.4366 0.6468 0.5029 0.9828 0.9323 0.3322 0.8083 0.8918 0.4116 0.9964 0.2228 0.6988 0.3087 0.4390 0.5781 0.6104 0.1747 0.6089 0.7597 0.1487 0.8344 0.0180 0.7130 0.9820 0.1029 0.0845 0.0231 0.8082 0.7549 0.2952 0.1860 0.4561 0.4008 0.4429 0.7431 0.7123 0.0993 0.6510 0.1243 0.0144 0.2396 0.2842 0.5099 0.7861 0.6856 0.8970 0.3957 0.9405 0.2870 0.5159 0.8765 0.6586 0.2746 0.3781 0.8939 0.6552 0.1924 0.2137 0.5626 0.1943 0.0306 0.5555 0.3782 0.2678 0.5802 0.0211 0.1821 0.4485 0.8296 0.8514 B(:,:,10) = 0.3617 0.3823 0.9691 0.8477 0.8383 0.0718 0.3922 0.1744 0.8076 0.0939 0.5989 0.1761 0.8859 0.8942 0.5644 0.7504 0.9283 0.7647 0.4875 0.6346 0.6725 0.1359 0.9393 0.9551 0.8496 0.1292 0.4113 0.4335 0.8027 0.1812 0.3302 0.4514 0.8300 0.6400 0.3009 0.7399 0.8408 0.8839 0.3461 0.9333 0.7028 0.6672 0.7423 0.3582 0.6960 0.3162 0.9593 0.0847 0.3185 0.2534 0.8700 0.3993 0.5180 0.8833 0.2730 0.2412 0.5344 0.2102 0.9623 0.6223 0.3975 0.4503 0.3173 0.3833 0.8598 0.0765 0.3006 0.5944 0.9422 0.9224 0.0755 0.8939 0.9821 0.3741 0.7460 0.5517 ...

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 = 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13

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 13 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

### Community Treasure Hunt

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

Start Hunting!