Cody

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

Solution 2541537

Submitted on 13 Jun 2020 by Ramesh Kumar V
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 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')

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

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

A = 0 0 0 0 0 8 0 25 2 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')

A(:,:,1) = 0.8218 0.0598 0.0788 0.8540 0.5390 0.3260 0.4434 0.9240 0.0092 0.6783 0.4289 0.7341 0.6258 0.6003 0.7043 0.1798 0.2887 0.4987 0.6466 0.1790 0.4971 0.9558 0.8695 0 0.4553 0.3492 0.2137 0.5201 0.3355 0.6321 0.3802 0.0423 0.1703 0.8491 0.6816 0.5573 0.4582 0.0216 0.7041 0.2997 0.7608 0.1237 0.9054 0.1882 0.4735 0.0301 0.9842 0.0750 0.8228 0.8164 0.1001 0.7321 0.1175 0.0531 0.3653 0.2873 0.3646 0.4855 0.7554 0.6692 0.2438 0.0223 0.6923 0.4098 0.0963 0.0157 0.5118 0.6343 0.8604 0.6756 0.4154 0.2544 0.6006 0.7141 0.9255 0.5212 0.4122 0.3257 0.1094 0.9347 0.8416 0.0710 0.2385 0.5464 0.8423 0.8779 0.3357 0.5964 0.4066 0.7466 0.3248 0.9807 0.5452 0.5780 0.0724 0.8833 0.1545 0.2925 0.7595 0.3927 A(:,:,2) = 0.5433 0 0.5440 0.8357 0.3696 0.5602 0.8629 0.6591 0.0261 0.2537 0.6559 0.4220 0.0272 0.4586 0.8585 0.0305 0.5242 0.1498 0.3742 0.4717 0.0484 0.3453 0.7429 0.0082 0.0943 0.2018 0.5714 0.6235 0.9769 0.7817 0.0979 0.3514 0.9353 0.8241 0.2394 0.3608 0.5635 0.4580 0.0157 0.9329 0.9665 0.7385 0.0550 0.0275 0.6296 0.9065 0.0200 0.5321 0.5820 0.4055 0.5674 0.2709 0.1086 0.0119 0.2914 0.2684 0.1822 0.5941 0.5206 0.6029 0.4311 0.7648 0.9103 0.0642 0.1459 0.9975 0.4928 0.1444 0.2017 0.9527 0.6910 0.8701 0.7353 0.4352 0.8104 0.3160 0.2978 0.9951 0.4018 0.1337 0.2025 0.3046 0.1503 0.0111 0.6227 0.2081 0.2684 0.9249 0.7013 0.1982 0.8511 0.0345 0.9163 0.6040 0.8968 0.5115 0.3275 0.1995 0.9240 0.2230 A(:,:,3) = 0.4414 0.3533 0.8857 0.2655 0.2465 0.9480 0.2903 0.9419 0.5513 0.8668 0.0710 0.6169 0.0191 0.6540 0.8326 0.4293 0.3812 0.1194 0.8613 0.0959 0.7499 0.8911 0.1146 0.3772 0.0614 0.9681 0.5629 0.5967 0.6209 0.4820 0.1988 0.6261 0.3775 0.9025 0.7716 0.8322 0.1209 0.2720 0.1884 0.3028 0.2403 0.4200 0.0991 0.0358 0.6737 0 0.3568 0.0244 0.0219 0.3452 0.9977 0.8109 0.7075 0.4823 0.3585 0.8138 0.2443 0.3922 0.6338 0.2942 0.1877 0.6038 0.4747 0.7045 0.9214 0.2811 0.1733 0.9561 0.9342 0.0411 0.9910 0.5942 0.1511 0.4251 0.7594 0.2853 0.5062 0.3734 0.1353 0.2500 0.9513 0.5353 0.6545 0.7587 0.4698 0.7993 0.9069 0.0413 0.6861 0.1953 0.4434 0.8473 0.5826 0.5060 0.2588 0.4201 0.9661 0.8879 0.3132 0.4348 A(:,:,4) = 0.1930 0.1803 0.0465 0.0837 0.1229 0.4752 0.4137 0.3249 0.2305 0.7302 0.7828 0.6295 0.6339 0.7030 0.6912 0.5161 0.2949 0.1861 0.8265 0.6843 0.4041 0.3011 0.4003 0.6272 0.0852 0.1131 0.1816 0.7878 0.1783 0.8811 0.6277 0.5593 0.6603 0.4540 0.1522 0.1961 0.4586 0.4868 0.4282 0.5172 0.5945 0.4647 0.0783 0.7107 0.3336 0.6746 0.8411 0.6304 0.0519 0.0705 0.6930 0.1782 0.2873 0.7505 0.8703 0.6174 0.1892 0.3688 0.1547 0.5843 0.0468 0.0525 0.2905 0.0975 0.8473 0.2396 0.2224 0.5524 0.0890 0.2986 0.5340 0.4173 0.9521 0.6032 0.4283 0.4525 0.0715 0.3348 0.3355 0.7159 0.0514 0.2005 0.8946 0.9670 0.3876 0.4754 0.8232 0.9628 0.2196 0.8002 0.3174 0.7379 0.0254 0.8196 0.2035 0.6420 0.5597 0.4770 0.8317 0.5832 A(:,:,5) = 0.9651 0.6019 0.3212 0.6843 0.2170 0.1324 0.6108 0.2275 0.5769 0.7543 0.7731 0.7680 0.5237 0.1764 0.6137 0.5141 0.2939 0.8903 0.9056 0.3377 0.3764 0.4315 0.0251 0.4269 0.0055 0.8222 0.3625 0.0225 0.0042 0.5650 0.6925 0.8406 0.7698 0.1805 0.9370 0.4498 0.0314 0.9411 0.8350 0.6193 0.9302 0.1342 0.0073 0.4290 0.4156 0.6481 0.1989 0.7954 0.2474 0.6841 0.8532 0.9783 0.4535 0.2886 0.1612 0.4871 0.5664 0.3965 0.8826 0.5073 0.0650 0.6540 0.8645 0.1764 0.9174 0.2957 0.4444 0.5764 0.5536 0.1362 0.5844 0.7051 0.7246 0.1088 0.0625 0.9002 0.6453 0.8948 0.8267 0.3387 0.8362 0.3277 0.2413 0.1171 0.6687 0.8805 0.6776 0.6373 0.8769 0.2911 0.8045 0.6426 0.1870 0.7845 0.5767 0.3957 0.9213 0.4603 0.7939 0.9516 A(:,:,6) = 0.7110 0.6330 0.8061 0.2908 0.4010 0.0889 0.4030 0.6731 0.3526 0.7802 0.6214 0.4907 0.7835 0.6803 0.6990 0.3765 0.1360 0.9982 0.9587 0.7239 0.9265 0.0754 0.2271 0.7038 0.7424 0.1582 0.1087 0.7821 0.7098 0.7748 0.1525 0.3292 0.7829 0.7926 0.5326 0.4493 0.1312 0.2006 0.5863 0.4853 0.5532 0.4769 0.5221 0.8976 0.2625 0.4525 0.0932 0.0218 0.5215 0.3014 0.5557 0.3871 0.3139 0.8866 0.9174 0.4851 0.3982 0.1521 0.0843 0.0793 0.1427 0.2813 0.7456 0.8343 0.1384 0.5240 0.7594 0.4701 0.4936 0.9393 0.9934 0.9490 0.1980 0.2652 0.6504 0.0864 0.1978 0.0702 0.4597 0.6209 0.8243 0.7661 0.1186 0.6402 0.7902 0.7553 0.3226 0.9792 0.1562 0.4826 0.9083 0.7245 0.8416 0.9964 0.8600 0.5142 0.5537 0.5939 0.9450 0.0083 A(:,:,7) = 0.5117 0.7670 0.4362 0.1573 0.9643 0.4686 0.5921 0.2799 0.3234 0.0225 0.5374 0.0502 0.9101 0.0367 0.7517 0.7191 0.6800 0.7346 0.9822 0.3980 0.3395 0.1429 0.6087 0.9495 0.1074 0.3497 0.9621 0.2049 0.9942 0.7876 0.7315 0.8804 0.3922 0.5555 0.0011 0.5174 0.9413 0.6756 0.9147 0.6144 0.8939 0.5383 0.4599 0.9387 0.9335 0.4563 0.4175 0.4869 0.0135 0.0098 0.5689 0.1370 0.3718 0.8088 0.9305 0.0339 0.6893 0.7363 0.5538 0.0876 0.9427 0.2541 0.3230 0.5861 0.7715 0.2522 0.1079 0.6290 0.5519 0.3190 0.6978 0.1315 0.3320 0.6244 0.8884 0.8017 0.0141 0.8021 0.5848 0.4110 0.6530 0.4737 0.9459 0.4508 0.0881 0.4801 0.2756 0.2768 0.9719 0.2825 0.3385 0.5766 0.1990 0.2784 0.9958 0.4335 0.1364 0.7665 0.0732 0.5258 A(:,:,8) = 0.0384 0.4212 0.9739 0.4471 0.7672 0.3853 0.3194 0.8606 0.1843 0.0105 0.7789 0.9007 0.2435 0.0643 0.9488 0.7504 0.5801 0.1685 0.3105 0.1439 0.0566 0.9565 0.8006 0.6386 0.2113 0.9345 0.0950 0.1750 0.6636 0.4778 0.8783 0.2509 0.3309 0.0866 0.9516 0.9465 0.0495 0.4800 0.3214 0.4723 0.2783 0.2128 0.7889 0.7189 0.1102 0.2288 0.2018 0.4138 0.0683 0.4221 0.5880 0.3484 0.7276 0.0399 0.3646 0.2402 0.8810 0.0241 0.1454 0.5737 0.4517 0.4498 0.4810 0.4560 0.2514 0.4768 0.3628 0.5710 0.1859 0.4958 0.5186 0.9422 0.1822 0.8138 0.0241 0.0490 0.6114 0.3865 0.2760 0.4853 0.8857 0.9853 0.3395 0.4944 0.2687 0.8323 0.1290 0.3927 0.3680 0.5053 0.3852 0.9274 0.7642 0.6295 0.3869 0.9975 0.2347 0.6348 0.0039 0.1487 A(:,:,9) = 0.6545 0.5841 0.5912 0.9174 0.0610 0.5864 0.7176 0.7469 0.3876 0.7859 0.3361 0.2782 0.9115 0.7619 0.2681 0.3616 0.6854 0.7798 0.5304 0.9567 0.1386 0.0698 0.5643 0.3633 0.4884 0.9263 0.3043 0.9178 0.4706 0.4050 0.1810 0.5889 0.1910 0.4703 0.1227 0.0253 0.5834 0.5312 0.2759 0.8400 0.3742 0.3768 0.3381 0.0609 0.0710 0.1665 0.9134 0.7064 0.6213 0.3817 0.5158 0.7763 0.8095 0.7006 0.2316 0.3143 0.1398 0.4084 0.7902 0.3607 0.5185 0.7282 0.9777 0.3835 0.4683 0.4268 0.6252 0.2316 0.9314 0.5891 0.7036 0.0375 0.5094 0.4474 0.8122 0.9703 0.8425 0.5360 0.5436 0.2179 0.1289 0.5497 0.2635 0.6368 0.1455 0.3766 0.5883 0.8809 0.6759 0.4517 0.7056 0.9470 0.2862 0.6599 0.0003 0.2808 0.5088 0.0052 0.8439 0.6348 A(:,:,10) = 0.3680 0.2056 0.7646 0.2533 0.1886 0.3090 0.5826 0.4110 0.1312 0.7271 0.2955 0.1456 0.9506 0.9689 0.2273 0.4570 0.0002 0.8295 0.2458 0.3651 0.8196 0.1420 0.0125 0.2019 0.9117 0.1061 0.9363 0.9727 0.1109 0.6711 0.3125 0.2418 0.8008 0.7792 0.1529 0.0306 0.1467 0.4114 0.1072 0.2812 0.3484 0.1002 0.6775 0.2044 0.6250 0.2610 0.1742 0.7179 0.2182 0.8830 0.3502 0.4497 0.8848 0.6963 0.8915 0.4436 0.0080 0.4911 0.1525 0.1712 0.9936 0.8309 0.6140 0.4042 0.9537 0.6061 0.4588 0.6814 0.7089 0.5247 0.7502 0.5473 0.4000 0.0465 0.1926 0.2426 ...

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 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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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 ...

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

A = 13.3000 B = 13.3000

### Community Treasure Hunt

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

Start Hunting!