Cody

# Problem 2670. Error handling

Solution 530032

Submitted on 17 Nov 2014 by Evan
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; clear y z; try y = check(x); catch z = 'error'; end end assert(isequal(y,x)) assert(isequal(exist('y','var'),1)) assert(isequal(exist('z','var'),0))

x = 0.4118 x = 0.4140 x = 0.4391 x = 0.1030 x = 0.8444 x = 0.9931 x = 0.4449 x = 0.8923 x = 0.4361 x = 0.2432 x = 0.9545 x = 0.0033 x = 0.5448 x = 0.7585 x = 0.9294 x = 0.7712 x = 0.5506 x = 0.5186 x = 0.5980 x = 0.7744 x = 0.1008 x = 0.9782 x = 0.9786 x = 0.5318 x = 0.8591 x = 0.2167 x = 0.3476 x = 0.4369 x = 0.3692 x = 0.7766 x = 0.7068 x = 0.4231 x = 0.8468 x = 0.0675 x = 0.2214 x = 0.7155 x = 0.5589 x = 0.2981 x = 0.7850 x = 0.5815 x = 0.4657 x = 0.7034 x = 0.6990 x = 0.8879 x = 0.9869 x = 0.5178 x = 0.3423 x = 0.0910 x = 0.7008 x = 0.4929 x = 0.6900 x = 0.4415 x = 0.0900 x = 0.1935 x = 0.1135 x = 0.2857 x = 0.2220 x = 0.0031 x = 0.5765 x = 0.9329 x = 0.2965 x = 0.5609 x = 0.3221 x = 0.9193 x = 0.1813 x = 0.3688 x = 0.8825 x = 0.0771 x = 0.3331 x = 0.1214 x = 0.8003 x = 0.9871 x = 0.7775 x = 0.3442 x = 0.0469 x = 0.0525 x = 0.1517 x = 0.0029 x = 0.7700 x = 0.3680 x = 0.7547 x = 0.6764 x = 0.7621 x = 0.7651 x = 0.1546 x = 0.0635 x = 0.4242 x = 0.7393 x = 0.6849 x = 0.5703 x = 0.3218 x = 0.9542 x = 0.9679 x = 0.1966 x = 0.5207 x = 0.8837 x = 0.0029 x = 0.2759 x = 0.3651 x = 0.7008

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

x = -0.4300 x = -0.9705 x = -0.1135 x = -0.6111 x = -0.7142 x = -0.3281 x = -0.2636 x = -0.2008 x = -0.5043 x = -0.2201 x = -0.8708 x = -0.8357 x = -0.5998 x = -0.0216 x = -0.0795 x = -0.1790 x = -0.0161 x = -0.5467 x = -0.7781 x = -0.1570 x = -0.6983 x = -0.3373 x = -0.7922 x = -0.2966 x = -0.4670 x = -0.6187 x = -0.4419 x = -0.1875 x = -0.4147 x = -0.4169 x = -0.0373 x = -0.5286 x = -0.8303 x = -0.0032 x = -0.1414 x = -0.5446 x = -0.8382 x = -0.9705 x = -0.6296 x = -0.6434 x = -0.6493 x = -0.1170 x = -0.5757 x = -0.5068 x = -0.7100 x = -0.8940 x = -0.8646 x = -0.6687 x = -0.7398 x = -0.0018 x = -0.6665 x = -0.0799 x = -0.1523 x = -0.8103 x = -0.5988 x = -0.4723 x = -0.9773 x = -0.1194 x = -0.8700 x = -0.5272 x = -0.5055 x = -0.9805 x = -0.9598 x = -0.0217 x = -0.6685 x = -0.8613 x = -0.1105 x = -0.1111 x = -0.1005 x = -0.1582 x = -0.0563 x = -0.4202 x = -0.5416 x = -0.7253 x = -0.0418 x = -0.2444 x = -0.4027 x = -0.8724 x = -0.3173 x = -0.9930 x = -0.6304 x = -0.7223 x = -0.4778 x = -0.5300 x = -0.7764 x = -0.6076 x = -0.9192 x = -0.3619 x = -0.4927 x = -0.2021 x = -0.2957 x = -0.6278 x = -0.9058 x = -0.8380 x = -0.3059 x = -0.0301 x = -0.9875 x = -0.7995 x = -0.8538 x = -0.9519