Cody

# Problem 1704. Triangular matrices in 3D array

Solution 452422

Submitted on 9 Jun 2014 by rifat
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
%% x(:,:,1) = [1 2 3;4 5 6;7 8 9]; x(:,:,2) = [1 4 7;2 5 8;3 6 9]; x(:,:,3) = [1 2 3;1 2 3;1 2 3]; y_correct(:,:,1) = [1 0 0;4 5 0;7 8 9]; y_correct(:,:,2) = [1 0 0;2 5 0;3 6 9]; y_correct(:,:,3) = [1 0 0;1 2 0;1 2 3]; assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 0 4 5 0 7 8 9 ans(:,:,2) = 1 0 0 2 5 0 3 6 9 ans(:,:,3) = 1 0 0 1 2 0 1 2 3

2   Pass
%% x = cumsum(ones(3,3,50)); y_correct = repmat([1 0 0;2 2 0; 3 3 3],[1,1,50]); assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 0 2 2 0 3 3 3 ans(:,:,2) = 1 0 0 2 2 0 3 3 3 ans(:,:,3) = 1 0 0 2 2 0 3 3 3 ans(:,:,4) = 1 0 0 2 2 0 3 3 3 ans(:,:,5) = 1 0 0 2 2 0 3 3 3 ans(:,:,6) = 1 0 0 2 2 0 3 3 3 ans(:,:,7) = 1 0 0 2 2 0 3 3 3 ans(:,:,8) = 1 0 0 2 2 0 3 3 3 ans(:,:,9) = 1 0 0 2 2 0 3 3 3 ans(:,:,10) = 1 0 0 2 2 0 3 3 3 ans(:,:,11) = 1 0 0 2 2 0 3 3 3 ans(:,:,12) = 1 0 0 2 2 0 3 3 3 ans(:,:,13) = 1 0 0 2 2 0 3 3 3 ans(:,:,14) = 1 0 0 2 2 0 3 3 3 ans(:,:,15) = 1 0 0 2 2 0 3 3 3 ans(:,:,16) = 1 0 0 2 2 0 3 3 3 ans(:,:,17) = 1 0 0 2 2 0 3 3 3 ans(:,:,18) = 1 0 0 2 2 0 3 3 3 ans(:,:,19) = 1 0 0 2 2 0 3 3 3 ans(:,:,20) = 1 0 0 2 2 0 3 3 3 ans(:,:,21) = 1 0 0 2 2 0 3 3 3 ans(:,:,22) = 1 0 0 2 2 0 3 3 3 ans(:,:,23) = 1 0 0 2 2 0 3 3 3 ans(:,:,24) = 1 0 0 2 2 0 3 3 3 ans(:,:,25) = 1 0 0 2 2 0 3 3 3 ans(:,:,26) = 1 0 0 2 2 0 3 3 3 ans(:,:,27) = 1 0 0 2 2 0 3 3 3 ans(:,:,28) = 1 0 0 2 2 0 3 3 3 ans(:,:,29) = 1 0 0 2 2 0 3 3 3 ans(:,:,30) = 1 0 0 2 2 0 3 3 3 ans(:,:,31) = 1 0 0 2 2 0 3 3 3 ans(:,:,32) = 1 0 0 2 2 0 3 3 3 ans(:,:,33) = 1 0 0 2 2 0 3 3 3 ans(:,:,34) = 1 0 0 2 2 0 3 3 3 ans(:,:,35) = 1 0 0 2 2 0 3 3 3 ans(:,:,36) = 1 0 0 2 2 0 3 3 3 ans(:,:,37) = 1 0 0 2 2 0 3 3 3 ans(:,:,38) = 1 0 0 2 2 0 3 3 3 ans(:,:,39) = 1 0 0 2 2 0 3 3 3 ans(:,:,40) = 1 0 0 2 2 0 3 3 3 ans(:,:,41) = 1 0 0 2 2 0 3 3 3 ans(:,:,42) = 1 0 0 2 2 0 3 3 3 ans(:,:,43) = 1 0 0 2 2 0 3 3 3 ans(:,:,44) = 1 0 0 2 2 0 3 3 3 ans(:,:,45) = 1 0 0 2 2 0 3 3 3 ans(:,:,46) = 1 0 0 2 2 0 3 3 3 ans(:,:,47) = 1 0 0 2 2 0 3 3 3 ans(:,:,48) = 1 0 0 2 2 0 3 3 3 ans(:,:,49) = 1 0 0 2 2 0 3 3 3 ans(:,:,50) = 1 0 0 2 2 0 3 3 3

3   Pass
%% x = cumsum(ones(5,5,100),2); y_correct = repmat(tril(cumsum(ones(5,5),2)),[1,1,100]); assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 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ans(:,:,52) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,53) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,54) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,55) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,56) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,57) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,58) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,59) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,60) = 1 0 0 ...

4   Pass
%% x = rand([1 1 400]); y_correct = x; assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 0.7157 ans(:,:,2) = 0.8390 ans(:,:,3) = 0.4333 ans(:,:,4) = 0.4706 ans(:,:,5) = 0.5607 ans(:,:,6) = 0.2691 ans(:,:,7) = 0.7490 ans(:,:,8) = 0.5039 ans(:,:,9) = 0.6468 ans(:,:,10) = 0.3077 ans(:,:,11) = 0.1387 ans(:,:,12) = 0.4756 ans(:,:,13) = 0.3625 ans(:,:,14) = 0.7881 ans(:,:,15) = 0.7803 ans(:,:,16) = 0.6685 ans(:,:,17) = 0.1335 ans(:,:,18) = 0.0216 ans(:,:,19) = 0.5598 ans(:,:,20) = 0.3008 ans(:,:,21) = 0.9394 ans(:,:,22) = 0.9809 ans(:,:,23) = 0.2866 ans(:,:,24) = 0.8008 ans(:,:,25) = 0.8961 ans(:,:,26) = 0.5975 ans(:,:,27) = 0.8840 ans(:,:,28) = 0.9437 ans(:,:,29) = 0.5492 ans(:,:,30) = 0.7284 ans(:,:,31) = 0.5768 ans(:,:,32) = 0.0259 ans(:,:,33) = 0.4465 ans(:,:,34) = 0.6463 ans(:,:,35) = 0.5212 ans(:,:,36) = 0.3723 ans(:,:,37) = 0.9371 ans(:,:,38) = 0.8295 ans(:,:,39) = 0.8491 ans(:,:,40) = 0.3725 ans(:,:,41) = 0.5932 ans(:,:,42) = 0.8726 ans(:,:,43) = 0.9335 ans(:,:,44) = 0.6685 ans(:,:,45) = 0.2068 ans(:,:,46) = 0.6539 ans(:,:,47) = 0.0721 ans(:,:,48) = 0.4067 ans(:,:,49) = 0.6669 ans(:,:,50) = 0.9337 ans(:,:,51) = 0.8110 ans(:,:,52) = 0.4845 ans(:,:,53) = 0.7567 ans(:,:,54) = 0.4170 ans(:,:,55) = 0.9718 ans(:,:,56) = 0.9880 ans(:,:,57) = 0.8641 ans(:,:,58) = 0.3889 ans(:,:,59) = 0.4547 ans(:,:,60) = 0.2467 ans(:,:,61) = 0.7844 ans(:,:,62) = 0.8828 ans(:,:,63) = 0.9137 ans(:,:,64) = 0.5583 ans(:,:,65) = 0.5989 ans(:,:,66) = 0.1489 ans(:,:,67) = 0.8997 ans(:,:,68) = 0.4504 ans(:,:,69) = 0.2057 ans(:,:,70) = 0.8997 ans(:,:,71) = 0.7626 ans(:,:,72) = 0.8825 ans(:,:,73) = 0.2850 ans(:,:,74) = 0.6732 ans(:,:,75) = 0.6643 ans(:,:,76) = 0.1228 ans(:,:,77) = 0.4073 ans(:,:,78) = 0.2753 ans(:,:,79) = 0.7167 ans(:,:,80) = 0.2834 ans(:,:,81) = 0.8962 ans(:,:,82) = 0.8266 ans(:,:,83) = 0.3900 ans(:,:,84) = 0.4979 ans(:,:,85) = 0.6948 ans(:,:,86) = 0.8344 ans(:,:,87) = 0.6096 ans(:,:,88) = 0.5747 ans(:,:,89) = 0.3260 ans(:,:,90) = 0.4564 ans(:,:,91) = 0.7138 ans(:,:,92) = 0.8844 ans(:,:,93) = 0.7209 ans(:,:,94) = 0.0186 ans(:,:,95) = 0.6748 ans(:,:,96) = 0.4385 ans(:,:,97) = 0.4378 ans(:,:,98) = 0.1170 ans(:,:,99) = 0.8147 ans(:,:,100) = 0.3249 ans(:,:,101) = 0.2462 ans(:,:,102) = 0.3427 ans(:,:,103) = 0.3757 ans(:,:,104) = 0.5466 ans(:,:,105) = 0.5619 ans(:,:,106) = 0.3958 ans(:,:,107) = 0.3981 ans(:,:,108) = 0.5154 ans(:,:,109) = 0.6575 ans(:,:,110) = 0.9509 ans(:,:,111) = 0.7223 ans(:,:,112) = 0.4001 ans(:,:,113) = 0.8319 ans(:,:,114) = 0.1343 ans(:,:,115) = 0.0605 ans(:,:,116) = 0.0842 ans(:,:,117) = 0.1639 ans(:,:,118) = 0.3242 ans(:,:,119) = 0.3017 ans(:,:,120) = 0.0117 ans(:,:,121) = 0.5399 ans(:,:,122) = 0.0954 ans(:,:,123) = 0.1465 ans(:,:,124) = 0.6311 ans(:,:,125) = 0.8593 ans(:,:,126) = 0.9742 ans(:,:,127) = 0.5708 ans(:,:,128) = 0.9969 ans(:,:,129) = 0.5535 ans(:,:,130) = 0.5155 ans(:,:,131) = 0.3307 ans(:,:,132) = 0.4300 ans(:,:,133) = 0.4918 ans(:,:,134) = 0.0710 ans(:,:,135) = 0.8877 ans(:,:,136) = 0.0646 ans(:,:,137) = 0.4362 ans(:,:,138) = 0.8266 ans(:,:,139) = 0.3945 ans(:,:,140) = 0.6135 ans(:,:,141) = 0.8186 ans(:,:,142) = 0.8862 ans(:,:,143) = 0.9311 ans(:,:,144) = 0.1908 ans(:,:,145) = 0.2586 ans(:,:,146) = 0.8979 ans(:,:,147) = 0.5934 ans(:,:,148) = 0.5038 ans(:,:,149) = 0.6128 ans(:,:,150) = 0.8194 ans(:,:,151) = 0.5319 ans(:,:,152) = 0.2021 ans(:,:,153) = 0.4539 ans(:,:,154) = 0.4279 ans(:,:,155) = 0.9661 ans(:,:,156) = 0.6201 ans(:,:,157) = 0.6954 ans(:,:,158) = 0.7202 ans(:,:,159) = 0.3469 ans(:,:,160) = 0.5170 ans(:,:,161) = 0.5567 ans(:,:,162) = 0.1565 ans(:,:,163) = 0.5621 ans(:,:,164) = 0.6948 ans(:,:,165) = 0.4265 ans(:,:,166) = 0.8363 ans(:,:,167) = 0.7314 ans(:,:,168) = 0.3600 ans(:,:,169) = 0.4542 ans(:,:,170) = 0.3864 ans(:,:,171) = 0.7756 ans(:,:,172) = 0.7343 ans(:,:,173) = 0.4303 ans(:,:,174) = 0.6938 ans(:,:,175) = 0.9452 ans(:,:,176) = 0.7842 ans(:,:,177) = 0.7056 ans(:,:,178) = 0.1093 ans(:,:,179) = 0.3899 ans(:,:,180) = 0.5909 ans(:,:,181) = 0.4594 ans(:,:,182) = 0.0503 ans(:,:,183) = 0.2287 ans(:,:,184) = 0.8342 ans(:,:,185) = 0.0156 ans(:,:,186) = 0.8637 ans(:,:,187) = 0.0781 ans(:,:,188) = 0.6690 ans(:,:,189) = 0.5002 ans(:,:,190) = 0.2180 ans(:,:,191) = 0.5716 ans(:,:,192) = 0.1222 ans(:,:,193) = 0.6712 ans(:,:,194) = 0.5996 ans(:,:,195) = 0.0560 ans(:,:,196) = 0.0563 ans(:,:,197) = 0.1525 ans(:,:,198) = 0.0196 ans(:,:,199) = 0.4352 ans(:,:,200) = 0.8322 ans(:,:,201) = 0.6174 ans(:,:,202) = 0.5201 ans(:,:,203) = 0.8639 ans(:,:,204) = 0.0977 ans(:,:,205) = 0.9081 ans(:,:,206) = 0.1080 ans(:,:,207) = 0.5170 ans(:,:,208) = 0.1432 ans(:,:,209) = 0.5594 ans(:,:,210) = 0.0046 ans(:,:,211) = 0.7667 ans(:,:,212) = 0.8487 ans(:,:,213) = 0.9168 ans(:,:,214) = 0.9870 ans(:,:,215) = 0.5051 ans(:,:,216) = 0.2714 ans(:,:,217) = 0.1008 ans(:,:,218) = 0.5078 ans(:,:,219) = 0.5856 ans(:,:,220) = 0.7629 ans(:,:,221) = 0.0830 ans(:,:,222) = 0.6616 ans(:,:,223) = 0.5170 ans(:,:,224) = 0.1710 ans(:,:,225) = 0.9386 ans(:,:,226) = 0.5905 ans(:,:,227) = 0.4406 ans(:,:,228) = 0.9419 ans(:,:,229) = 0.6559 ans(:,:,230) = 0.4519 ans(:,:,231) = 0.8397 ans(:,:,232) = 0.5326 ans(:,:,233) = 0.5539 ans(:,:,234) = 0.6801 ans(:,:,235) = 0.3672 ans(:,:,236) = 0.2393 ans(:,:,237) = 0.5789 ans(:,:,238) = 0.8669 ans(:,:,239) = 0.4068 ans(:,:,240) = 0.1126 ans(:,:,241) = 0.4438 ans(:,:,242) = 0.3002 ans(:,:,243) = 0.4014 ans(:,:,244) = 0.8334 ans(:,:,245) = 0.4036 ans(:,:,246) = 0.3902 ans(:,:,247) = 0.3604 ans(:,:,248) = 0.1403 ans(:,:,249) = 0.2601 ans(:,:,250) = 0.0868 ans(:,:,251) = 0.4294 ans(:,:,252) = 0.2573 ans(:,:,253) = 0.2976 ans(:,:,254) = 0.4249 ans(:,:,255) = 0.1192 ans(:,:,256) = 0.4951 ans(:,:,257) = 0.7064 ans(:,:,258) = 0.2436 ans(:,:,259) = 0.7851 ans(:,:,260) = 0.0741 ans(:,:,261) = 0.3939 ans(:,:,262) = 0.0034 ans(:,:,263) = 0.2207 ans(:,:,264) = 0.0013 ans(:,:,265) = 0.1892 ans(:,:,266) = 0.1425 ans(:,:,267) = 0.2681 ans(:,:,268) = 0.1749 ans(:,:,269) = 0.1386 ans(:,:,270) = 0.5989 ans(:,:,271) = 0.9011 ans(:,:,272) = 0.9394 ans(:,:,273) = 0.2212 ans(:,:,274) = 0.4827 ans(:,:,275) = 0.3760 ans(:,:,276) = 0.5238 ans(:,:,277) = 0.2649 ans(:,:,278) = 0.0684 ans(:,:,279) = 0.4363 ans(:,:,280) = 0.1739 ans(:,:,281) = 0.0261 ans(:,:,282) = 0.9547 ans(:,:,283) = 0.4306 ans(:,:,284) = 0.9616 ans(:,:,285) = 0.7624 ans(:,:,286) = 0.0073 ans(:,:,287) = 0.6800 ans(:,:,288) = 0.7060 ans(:,:,289) = 0.6451 ans(:,:,290) = 0.5523 ans(:,:,291) = 0.2181 ans(:,:,292) = 0.7724 ans(:,:,293) = 0.2280 ans(:,:,294) = 0.3709 ans(:,:,295) = 0.8909 ans(:,:,296) = 0.8564 ans(:,:,297) = 0.4024 ans(:,:,298) = 0.3180 ans(:,:,299) = 0.6086 ans(:,:,300) = 0.9102 ans(:,:,301) = 0.9091 ans(:,:,302) = 0.5916 ans(:,:,303) = 0.3326 ans(:,:,304) = 0.8531 ans(:,:,305) = 0.4424 ans(:,:,306) = 0.9044 ans(:,:,307) = 0.0332 ans(:,:,308) = 0.5324 ans(:,:,309) = 0.7165 ans(:,:,310) = 0.1793 ans(:,:,311) = 0.3365 ans(:,:,312) = 0.1877 ans(:,:,313) = 0.3219 ans(:,:,314) = 0.4039 ans(:,:,315) = 0.5486 ans(:,:,316) = 0.0487 ans(:,:,317) = 0.5527 ans(:,:,318) = 0.2748 ans(:,:,319) = 0.2415 ans(:,:,320) = 0.2431 ans(:,:,321) = 0.1542 ans(:,:,322) = 0.9564 ans(:,:,323) = 0.9357 ans(:,:,324) = 0.8187 ans(:,:,325) = 0.7283 ans(:,:,326) = 0.1758 ans(:,:,327) = 0.3604 ans(:,:,328) = 0.1888 ans(:,:,329) = 0.0012 ans(:,:,330) = 0.3164 ans(:,:,331) = 0.6996 ans(:,:,332) = 0.6253 ans(:,:,333) = 0.5431 ans(:,:,334) = 0.4390 ans(:,:,335) = 0.2874 ans(:,:,336) = 0.5017 ans(:,:,337) = 0.7615 ans(:,:,338) = 0.7624 ans(:,:,339) = 0.5761 ans(:,:,340) = 0.7477 ans(:,:,341) = 0.6455 ans(:,:,342) = 0.1232 ans(:,:,343) = 0.5044 ans(:,:,344) = 0.3473 ans(:,:,345) = 0.0921 ans(:,:,346) = 0.1478 ans(:,:,347) = 0.1982 ans(:,:,348) = 0.6723 ans(:,:,349) = 0.4315 ans(:,:,350) = 0.6944 ans(:,:,351) = 0.2568 ans(:,:,352) = 0.0098 ans(:,:,353) = 0.5323 ans(:,:,354) = 0.2794 ans(:,:,355) = 0.9462 ans(:,:,356) = 0.9064 ans(:,:,357) = 0.3927 ans(:,:,358) = 0.0249 ans(:,:,359) = 0.6714 ans(:,:,360) = 0.8372 ans(:,:,361) = 0.9715 ans(:,:,362) = 0.0569 ans(:,:,363) = 0.4503 ans(:,:,364) = 0.5825 ans(:,:,365) = 0.6866 ans(:,:,366) = 0.7194 ans(:,:,367) = 0.6500 ans(:,:,368) = 0.7269 ans(:,:,369) = 0.3738 ans(:,:,370) = 0.5816 ans(:,:,371) = 0.1161 ans(:,:,372) = 0.0577 ans(:,:,373) = 0.9798 ans(:,:,374) = 0.2848 ans(:,:,375) = 0.5950 ans(:,:,376) = 0.9622 ans(:,:,377) = 0.1858 ans(:,:,378) = 0.1930 ans(:,:,379) = 0.3416 ans(:,:,380) = 0.9329 ans(:,:,381) = 0.3907 ans(:,:,382) = 0.2732 ans(:,:,383) = 0.1519 ans(:,:,384) = 0.3971 ans(:,:,385) = 0.3747 ans(:,:,386) = 0.1311 ans(:,:,387) = 0.4350 ans(:,:,388) = 0.0915 ans(:,:,389) = ...

5   Fail
%% x = reshape(1:40,[2,2,10]); y_correct(:,:,1) = [1 0;2 4]; y_correct(:,:,2) = [5 0;6 8]; y_correct(:,:,3) = [9 0;10 12]; y_correct(:,:,4) = [13 0;14 16]; y_correct(:,:,5) = [17 0;18 20]; y_correct(:,:,6) = [21 0;22 24]; y_correct(:,:,7) = [25 0;26 28]; y_correct(:,:,8) = [29 0;30 32]; y_correct(:,:,9) = [33 0;34 36]; y_correct(:,:,10) = [37 0;38 40]; assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 2 4 ans(:,:,2) = 5 0 6 8 ans(:,:,3) = 9 0 10 12 ans(:,:,4) = 13 0 14 16 ans(:,:,5) = 17 0 18 20 ans(:,:,6) = 21 0 22 24 ans(:,:,7) = 25 0 26 28 ans(:,:,8) = 29 0 30 32 ans(:,:,9) = 33 0 34 36 ans(:,:,10) =

### Community Treasure Hunt

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

Start Hunting!