Cody

Solution 1727623

Submitted on 15 Feb 2019 by malues
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.2037 0.1073 0.1027 0.8119 0.6342 0.6956 0.0513 0.0542 0.6233 0.8086 0.9533 0.3981 0.0119 0.8353 0.4039 0.7833 0.3775 0.7742 0.2290 0.6193 0.1787 0.7672 0.3415 0 0.7229 0.4139 0.4982 0.4841 0.0991 0.7374 0.2625 0.5853 0.1925 0.9984 0.8615 0.9901 0.6675 0.9142 0.7965 0.5148 0.0483 0.9970 0.7319 0.0910 0.9211 0.0369 0.6844 0.7351 0.7870 0.8503 0.9091 0.3599 0.5194 0.6417 0.1990 0.6970 0.3478 0.2624 0.4860 0.0874 0.1810 0.0693 0.9024 0.9516 0.1943 0.7577 0.8723 0.0187 0.6457 0.6890 0.4247 0.3363 0.6780 0.6686 0.4101 0.0625 0.5331 0.8295 0.1069 0.3327 0.8524 0.4938 0.7648 0.0385 0.5734 0.8937 0.6363 0.2215 0.8161 0.8209 0.7842 0.0187 0.2637 0.1014 0.4121 0.7386 0.4338 0.3288 0.7888 0.3147 A(:,:,2) = 0.1689 0 0.4455 0.3779 0.9995 0.7971 0.2488 0.9896 0.4553 0.3626 0.1837 0.8424 0.2552 0.7871 0.6773 0.9242 0.0510 0.3118 0.5365 0.8993 0.4343 0.6136 0.0201 0.6521 0.6758 0.7996 0.8937 0.3294 0.3019 0.8741 0.8412 0.6710 0.9760 0.9531 0.8889 0.5333 0.7129 0.0115 0.9306 0.7898 0.8871 0.7466 0.5883 0.0667 0.8531 0.3091 0.3797 0.7764 0.3073 0.5109 0.6043 0.6994 0.1004 0.1076 0.5984 0.5494 0.9454 0.6895 0.5685 0.1092 0.5511 0.5565 0.7816 0.7478 0.2258 0.9363 0.7803 0.3113 0.2765 0.4267 0.3927 0.1151 0.0436 0.2563 0.8659 0.4514 0.4425 0.7899 0.2939 0.5680 0.4410 0.7090 0.9063 0.7319 0.5965 0.9492 0.7984 0.9508 0.2817 0.5463 0.9467 0.6937 0.6708 0.2942 0.1651 0.1204 0.4350 0.4909 0.7454 0.8942 A(:,:,3) = 0.5121 0.2765 0.3278 0.0946 0.6337 0.1177 0.5703 0.4525 0.9644 0.0764 0.9305 0.6830 0.3177 0.8829 0.4245 0.0286 0.6110 0.0447 0.4230 0.3307 0.1865 0.0459 0.0712 0.1077 0.0659 0.5443 0.6610 0.7417 0.3105 0.0775 0.6628 0.8550 0.2319 0.2612 0.0266 0.1470 0.4924 0.7177 0.6762 0.3144 0.2329 0.8544 0.8614 0.2621 0.0970 0 0.5197 0.5616 0.3929 0.8350 0.2463 0.5206 0.5394 0.8121 0.7303 0.0143 0.1300 0.4006 0.3928 0.2049 0.1121 0.3932 0.9877 0.7634 0.6453 0.2662 0.1140 0.3376 0.6347 0.3458 0.7966 0.0486 0.6111 0.2072 0.6178 0.1394 0.6115 0.8636 0.8186 0.8052 0.3620 0.2626 0.1200 0.1006 0.1903 0.0170 0.2118 0.2682 0.8860 0.2659 0.3288 0.5626 0.2795 0.1733 0.3426 0.8608 0.0715 0.9490 0.3031 0.9740 A(:,:,4) = 0.4631 0.6369 0.9624 0.4243 0.4847 0.0880 0.0507 0.6078 0.8250 0.0198 0.6590 0.1591 0.3399 0.1831 0.2785 0.0610 0.7816 0.3979 0.6862 0.4574 0.7511 0.5415 0.8804 0.1417 0.1380 0.7722 0.3559 0.3161 0.4710 0.2960 0.2679 0.1732 0.2694 0.9872 0.4916 0.0573 0.4912 0.9534 0.6067 0.4709 0.8852 0.4817 0.7036 0.0552 0.8487 0.6511 0.5603 0.6648 0.8327 0.5476 0.5908 0.1407 0.8156 0.6972 0.3392 0.3183 0.4276 0.7094 0.6508 0.5398 0.6249 0.0283 0.1383 0.2006 0.1235 0.1306 0.0264 0.2614 0.8156 0.0622 0.6262 0.3472 0.0844 0.3076 0.5306 0.9391 0.0428 0.9562 0.8932 0.8196 0.3955 0.3810 0.0722 0.0271 0.0253 0.8579 0.1828 0.3220 0.0883 0.7400 0.9581 0.5981 0.4918 0.4942 0.1918 0.4759 0.5841 0.7739 0.6298 0.2031 A(:,:,5) = 0.3531 0.6397 0.2681 0.6217 0.0371 0.7736 0.0467 0.7509 0.4096 0.8882 0.6574 0.4511 0.6243 0.3540 0.1872 0.7727 0.2747 0.3693 0.4182 0.9511 0.6692 0.5456 0.5840 0.5595 0.0188 0.3842 0.9180 0.1873 0.2677 0.7388 0.6904 0.8949 0.3573 0.6653 0.7260 0.1625 0.1827 0.8485 0.1193 0.0702 0.7690 0.4996 0.1212 0.1790 0.3222 0.3512 0.1374 0.7314 0.3230 0.8421 0.4665 0.6538 0.6155 0.5735 0.0985 0.5449 0.1812 0.1395 0.2393 0.0556 0.2304 0.3534 0.9286 0.2367 0.0109 0.2460 0.0436 0.7853 0.2464 0.0186 0.2925 0.9002 0.3961 0.5798 0.7246 0.2008 0.2275 0.9201 0.7062 0.7032 0.7336 0.4851 0.1385 0.9722 0.0057 0.5690 0.3337 0.9791 0.9162 0.7173 0.6577 0.5285 0.6904 0.3694 0.2467 0.5874 0.0535 0.1705 0.6639 0.5534 A(:,:,6) = 0.2560 0.9280 0.2147 0.0619 0.9013 0.5209 0.2758 0.7432 0.5397 0.3803 0.6005 0.2556 0.6376 0.3531 0.7679 0.7053 0.9778 0.4159 0.6653 0.8213 0.1357 0.7344 0.7203 0.8657 0.1872 0.5577 0.9252 0.7615 0.9993 0.0297 0.7378 0.3633 0.2444 0.5085 0.7219 0.3144 0.0848 0.7013 0.9419 0.4589 0.2251 0.3359 0.3933 0.9294 0.3749 0.0771 0.0465 0.1533 0.8715 0.7624 0.8780 0.0836 0.1151 0.9960 0.1738 0.9443 0.2116 0.8344 0.9997 0.3046 0.3037 0.3072 0.9335 0.8949 0.9061 0.3199 0.6883 0.6396 0.0761 0.4393 0.7830 0.4175 0.4069 0.5445 0.4502 0.1297 0.4368 0.0815 0.0991 0.9039 0.3850 0.4651 0.1953 0.9199 0.5778 0.2456 0.8860 0.9663 0.3797 0.2404 0.1494 0.6121 0.8399 0.7224 0.2386 0.7878 0.0999 0.6335 0.6173 0.0874 A(:,:,7) = 0.2977 0.2887 0.0888 0.0209 0.0161 0.1828 0.4171 0.3416 0.5478 0.5947 0.6116 0.9610 0.8337 0.2181 0.8293 0.9890 0.3070 0.2280 0.5221 0.4118 0.1094 0.2205 0.9926 0.5104 0.3167 0.5114 0.7557 0.4486 0.1804 0.0256 0.2135 0.1428 0.1067 0.0410 0.5661 0.3064 0.9820 0.9136 0.4585 0.5577 0.7344 0.1280 0.9669 0.3091 0.9642 0.2770 0.2931 0.9783 0.8600 0.7891 0.1968 0.0637 0.2538 0.5766 0.4599 0.7524 0.4252 0.7629 0.0634 0.6098 0.2759 0.1920 0.0202 0.6347 0.1962 0.3108 0.9810 0.2304 0.4591 0.9313 0.5455 0.1041 0.3842 0.0027 0.4415 0.5437 0.4916 0.0002 0.8324 0.2421 0.7357 0.8297 0.3115 0.1494 0.4243 0.9323 0.6162 0.4625 0.7763 0.8412 0.3606 0.9424 0.1345 0.8501 0.4063 0.1404 0.4134 0.5746 0.3287 0.8081 A(:,:,8) = 0.0781 0.5062 0.9235 0.4483 0.9604 0.0598 0.7578 0.7044 0.0846 0.8160 0.0254 0.7985 0.8227 0.5170 0.5714 0.9131 0.1117 0.5536 0.9563 0.2607 0.2537 0.5141 0.7407 0.6283 0.2472 0.3497 0.4989 0.2547 0.7204 0.9063 0.5445 0.4406 0.0937 0.3647 0.6492 0.0282 0.6762 0.0789 0.4933 0.7676 0.7105 0.6476 0.8943 0.8568 0.9697 0.8111 0.6137 0.8268 0.1568 0.7333 0.2718 0.2869 0.1483 0.3077 0.2665 0.5631 0.7636 0.6644 0.5838 0.0211 0.6883 0.2861 0.4593 0.7185 0.3009 0.0973 0.1877 0.0536 0.6229 0.9315 0.2488 0.6310 0.3458 0.7537 0.1831 0.5904 0.1052 0.3309 0.5288 0.4385 0.3683 0.8764 0.9324 0.0038 0.6304 0.1764 0.3601 0.8252 0.8175 0.8773 0.0500 0.4779 0.1981 0.5282 0.2253 0.4048 0.9444 0.4315 0.7755 0.6841 A(:,:,9) = 0.5705 0.6038 0.6961 0.7339 0.2003 0.2884 0.3412 0.5201 0.9260 0.4904 0.3688 0.7570 0.1930 0.8506 0.9296 0.9396 0.8839 0.5956 0.2788 0.4508 0.1000 0.3873 0.6743 0.8849 0.6896 0.5864 0.7786 0.5597 0.2680 0.1373 0.4930 0.3397 0.7931 0.8191 0.0410 0.4528 0.8386 0.0179 0.9184 0.9640 0.4768 0.6533 0.5116 0.8007 0.9633 0.0974 0.6950 0.4892 0.5194 0.0635 0.9847 0.0818 0.8156 0.9829 0.8486 0.4945 0.9002 0.9192 0.8297 0.5401 0.6680 0.0112 0.9704 0.5233 0.2688 0.7063 0.9092 0.7809 0.9817 0.8726 0.9362 0.4899 0.7743 0.6164 0.7026 0.2016 0.2060 0.0100 0.4012 0.9614 0.9472 0.4982 0.4831 0.4115 0.9161 0.2869 0.3692 0.7733 0.9137 0.1133 0.5251 0.4862 0.6487 0.8417 0.5051 0.4365 0.8274 0.5999 0.1027 0.9641 A(:,:,10) = 0.4589 0.0012 0.8532 0.6500 0.8389 0.9133 0.9489 0.2440 0.4043 0.8853 0.9832 0.3011 0.9184 0.5664 0.2645 0.9791 0.9863 0.3037 0.2945 0.6563 0.3536 0.1866 0.0155 0.0070 0.8091 0.3204 0.8810 0.7856 0.3203 0.0731 0.2742 0.3179 0.9616 0.3307 0.2892 0.2653 0.0832 0.9545 0.5857 0.9716 0.6971 0.6192 0.6903 0.6667 0.5210 0.0413 0.0770 0.6143 0.1088 0.2895 0.9863 0.4041 0.9264 0.7491 0.6440 0.8831 0.9449 0.3383 0.9748 0.7868 0.3327 0.1984 0.8906 0.2090 0.0183 0.2226 0.2549 0.3144 0.0506 0.2063 0.2432 0.6528 0.1307 0.9300 0.9484 0.2885 ...

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

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

Suggested Problems