Which version of MATLAB are you using on your desktop? I tried running your solution on MATLAB desktop version 2019a and the solution is failing with correct assertions. In order to figure out the version of MATLAB, command "ver' will get you the version.