Cody

Solution 669826

Submitted on 13 May 2015 by Jonathan Campelli
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 = rand(2,3,1,4); y_correct = 3; assert(isequal(ndims(remove_dims(x)),y_correct))

ans(:,:,1) = 0.8722 0.6290 0.5360 0.2108 0.2085 0.2849 ans(:,:,2) = 0.6353 0.9648 0.0537 0.4870 0.5866 0.6675 ans(:,:,3) = 0.2651 0.7986 0.4990 0.2895 0.1664 0.0465 ans(:,:,4) = 0.6124 0.9208 0.3652 0.6815 0.0973 0.5537

2   Pass
%% x = rand(2,3,4); y_correct = 3; assert(isequal(ndims(remove_dims(x)),y_correct))

ans(:,:,1) = 0.2426 0.1241 0.2024 0.9083 0.5772 0.0066 ans(:,:,2) = 0.7048 0.9106 0.5412 0.5728 0.2287 0.6693 ans(:,:,3) = 0.7922 0.3875 0.9282 0.1853 0.7613 0.3119 ans(:,:,4) = 0.9737 0.0002 0.1777 0.3147 0.1610 0.5533

3   Pass
%% x = rand(1,2,3,4,5); y_correct = 4; assert(isequal(ndims(remove_dims(x)),y_correct))

ans(:,:,1,1) = 0.5244 0.8841 0.0638 0.0766 0.6242 0.6475 ans(:,:,2,1) = 0.4498 0.7287 0.5710 0.2841 0.0075 0.3314 ans(:,:,3,1) = 0.7655 0.6992 0.5062 0.2113 0.8769 0.7637 ans(:,:,4,1) = 0.8501 0.6770 0.6879 0.0627 0.7057 0.2111 ans(:,:,1,2) = 0.0103 0.7343 0.6762 0.8320 0.0165 0.3470 ans(:,:,2,2) = 0.5360 0.6911 0.5072 0.3808 0.0955 0.3426 ans(:,:,3,2) = 0.5085 0.7653 0.3603 0.0781 0.5485 0.6987 ans(:,:,4,2) = 0.3499 0.0902 0.9913 0.0423 0.0437 0.2137 ans(:,:,1,3) = 0.7816 0.3268 0.3095 0.6662 0.0271 0.9893 ans(:,:,2,3) = 0.0588 0.6558 0.0741 0.1271 0.9004 0.9358 ans(:,:,3,3) = 0.5874 0.9340 0.0785 0.1248 0.6845 0.1124 ans(:,:,4,3) = 0.3018 0.0888 0.9185 0.8356 0.7920 0.1871 ans(:,:,1,4) = 0.9472 0.5041 0.7664 0.1172 0.6259 0.1486 ans(:,:,2,4) = 0.1974 0.0881 0.9377 0.3730 0.4924 0.8623 ans(:,:,3,4) = 0.0737 0.1088 0.3915 0.3231 0.1900 0.3691 ans(:,:,4,4) = 0.8659 0.5487 0.0235 0.7471 0.2490 0.7266 ans(:,:,1,5) = 0.9741 0.0628 0.6007 0.0252 0.4755 0.2612 ans(:,:,2,5) = 0.9362 0.5742 0.9612 0.5629 0.9587 0.1645 ans(:,:,3,5) = 0.4931 0.7434 0.8270 0.7586 0.6564 0.8688 ans(:,:,4,5) = 0.5046 0.0559 0.1960 0.3589 0.6836 0.5956