Cody

# Problem 2670. Error handling

Solution 527823

Submitted on 13 Nov 2014 by Zikobrelli
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
%% for ii=1:100 x = rand; try y = check(x); catch y = 'error'; end end assert(isequal(y,x))

x = 0.2398 x = 0.2296 x = 0.8020 x = 0.4885 x = 0.7573 x = 0.7126 x = 0.2681 x = 0.4999 x = 0.7979 x = 0.0345 x = 0.4708 x = 0.7648 x = 0.8597 x = 0.8060 x = 0.0842 x = 0.9358 x = 0.3045 x = 0.1982 x = 0.9614 x = 0.9578 x = 0.9405 x = 0.9997 x = 0.7354 x = 0.5448 x = 0.5871 x = 0.5840 x = 0.0708 x = 0.4755 x = 0.5145 x = 0.5241 x = 0.1042 x = 0.9485 x = 0.9455 x = 0.0699 x = 0.3185 x = 0.9919 x = 0.5733 x = 0.0241 x = 0.2328 x = 0.4492 x = 0.1300 x = 0.8167 x = 0.3541 x = 0.3837 x = 0.9543 x = 0.1681 x = 0.7373 x = 0.5174 x = 0.6354 x = 0.9818 x = 0.9018 x = 0.8269 x = 0.5613 x = 0.6814 x = 0.2480 x = 0.1353 x = 0.5499 x = 0.7883 x = 0.2921 x = 0.5745 x = 0.0910 x = 0.0909 x = 0.1704 x = 0.4107 x = 0.5224 x = 0.4583 x = 0.2940 x = 0.6797 x = 0.3678 x = 0.4263 x = 0.7444 x = 0.8870 x = 0.2759 x = 0.1349 x = 0.9626 x = 0.2014 x = 0.7223 x = 0.4105 x = 0.7936 x = 0.8816 x = 0.1228 x = 0.4040 x = 0.4762 x = 0.3831 x = 0.7708 x = 0.8878 x = 0.6111 x = 0.7419 x = 0.1780 x = 0.9579 x = 0.6198 x = 0.4999 x = 0.2345 x = 0.2573 x = 0.6066 x = 0.0726 x = 0.3248 x = 0.3137 x = 0.7043 x = 0.0754

2   Pass
%% for ii=1:100 x = -rand; try y = check(x); catch y = 'error'; end end assert(isequal(y,'error'))

x = -0.7752 ans = error x = -0.5789 ans = error x = -0.3975 ans = error x = -0.8981 ans = error x = -0.4373 ans = error x = -0.6531 ans = error x = -0.0548 ans = error x = -0.5216 ans = error x = -0.9310 ans = error x = -0.8658 ans = error x = -0.3893 ans = error x = -0.8634 ans = error x = -0.2844 ans = error x = -0.5350 ans = error x = -0.2574 ans = error x = -0.3156 ans = error x = -0.1306 ans = error x = -0.3175 ans = error x = -0.4038 ans = error x = -0.6418 ans = error x = -0.7677 ans = error x = -0.2948 ans = error x = -0.3580 ans = error x = -0.4287 ans = error x = -0.7829 ans = error x = -0.2932 ans = error x = -0.8306 ans = error x = -0.1021 ans = error x = -0.7272 ans = error x = -0.1631 ans = error x = -0.9202 ans = error x = -0.3110 ans = error x = -0.7622 ans = error x = -0.9841 ans = error x = -0.9045 ans = error x = -0.5464 ans = error x = -0.0087 ans = error x = -0.5170 ans = error x = -0.3819 ans = error x = -0.0413 ans = error x = -0.6796 ans = error x = -0.4356 ans = error x = -0.8253 ans = error x = -0.8094 ans = error x = -0.5205 ans = error x = -0.1573 ans = error x = -0.7331 ans = error x = -0.2903 ans = error x = -0.6944 ans = error x = -0.8189 ans = error x = -0.8693 ans = error x = -0.7700 ans = error x = -0.3989 ans = error x = -0.5270 ans = error x = -0.8614 ans = error x = -0.3544 ans = error x = -0.4087 ans = error x = -0.2910 ans = error x = -0.1312 ans = error x = -0.1920 ans = error x = -0.1759 ans = error x = -0.7311 ans = error x = -0.4542 ans = error x = -0.8941 ans = error x = -0.5355 ans = error x = -0.2353 ans = error x = -0.0219 ans = error x = -0.2128 ans = error x = -0.6723 ans = error x = -0.1533 ans = error x = -0.0355 ans = error x = -0.9868 ans = error x = -0.2356 ans = error x = -0.7778 ans = error x = -0.9265 ans = error x = -0.1878 ans = error x = -0.2129 ans = error x = -0.8627 ans = error x = -0.5265 ans = error x = -0.0966 ans = error x = -0.9116 ans = error x = -0.6930 ans = error x = -0.2409 ans = error x = -0.7799 ans = error x = -0.7333 ans = error x = -0.2290 ans = error x = -0.5505 ans = error x = -0.5637 ans = error x = -0.2811 ans = error x = -0.3743 ans = error x = -0.7387 ans = error x = -0.8023 ans = error x = -0.8619 ans = error x = -0.4231 ans = error x = -0.7167 ans = error x = -0.7928 ans = error x = -0.1915 ans = error x = -0.8100 ans = error x = -0.5948 ans = error x = -0.6520 ans = error

### Community Treasure Hunt

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

Start Hunting!