Cody

Solution 232167

Submitted on 18 Apr 2013 by andrea84
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.0821 0.1420 0.6210 0.1057 0.1665 0.5737 ans(:,:,2) = 0.0521 0.7287 0.0634 0.9312 0.7378 0.8604 ans(:,:,3) = 0.9344 0.8589 0.5134 0.9844 0.7856 0.1776 ans(:,:,4) = 0.3986 0.0309 0.3013 0.1339 0.9391 0.2955
2   Pass
%% x = rand(2,3,4); y_correct = 3; assert(isequal(ndims(remove_dims(x)),y_correct))
ans(:,:,1) = 0.3329 0.6482 0.8422 0.4671 0.0252 0.5590 ans(:,:,2) = 0.8541 0.4460 0.1771 0.3479 0.0542 0.6628 ans(:,:,3) = 0.3308 0.1182 0.5400 0.8985 0.9884 0.7069 ans(:,:,4) = 0.9995 0.4145 0.7640 0.2878 0.4648 0.8182
3   Pass
%% x = rand(1,2,3,4,5); y_correct = 4; assert(isequal(ndims(remove_dims(x)),y_correct))
ans(:,:,1,1) = 0.1002 0.3596 0.5219 0.1781 0.0567 0.3358 ans(:,:,2,1) = 0.1757 0.9052 0.4685 0.2089 0.6754 0.9121 ans(:,:,3,1) = 0.1040 0.7363 0.1842 0.7455 0.5619 0.5972 ans(:,:,4,1) = 0.2999 0.2126 0.0715 0.1341 0.8949 0.2425 ans(:,:,1,2) = 0.0538 0.0133 0.1967 0.4417 0.8972 0.0934 ans(:,:,2,2) = 0.3074 0.1017 0.3321 0.4561 0.9954 0.2973 ans(:,:,3,2) = 0.0620 0.0464 0.7614 0.2982 0.5054 0.6311 ans(:,:,4,2) = 0.0899 0.7772 0.5338 0.0809 0.9051 0.1092 ans(:,:,1,3) = 0.8258 0.2940 0.0103 0.3381 0.7463 0.0484 ans(:,:,2,3) = 0.6679 0.5261 0.7073 0.6035 0.7297 0.7814 ans(:,:,3,3) = 0.2880 0.5567 0.0616 0.6925 0.3965 0.7802 ans(:,:,4,3) = 0.3376 0.7413 0.1279 0.6079 0.1048 0.5495 ans(:,:,1,4) = 0.4852 0.7990 0.0513 0.8905 0.7343 0.0729 ans(:,:,2,4) = 0.0885 0.9430 0.1321 0.7984 0.6837 0.7227 ans(:,:,3,4) = 0.1104 0.6407 0.6538 0.1175 0.3288 0.7491 ans(:,:,4,4) = 0.5832 0.2348 0.9706 0.7400 0.7350 0.8669 ans(:,:,1,5) = 0.0862 0.3692 0.5979 0.3664 0.6850 0.7894 ans(:,:,2,5) = 0.3677 0.0867 0.2057 0.2060 0.7719 0.3883 ans(:,:,3,5) = 0.5518 0.6419 0.1518 0.2290 0.4845 0.7819 ans(:,:,4,5) = 0.1006 0.2374 0.0915 0.2941 0.5309 0.4053