Try restarting MATLAB and running just
>> cw, scope, target = cwconnect()
>> [textout, trace] = measure_AES(scope, target, [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15],[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15])
OR METHOD 2
>> cw = py.importlib.import_module('chipwhisperer')
>> scope = cw.scope()
>> target = cw.target(scope)
If you choose the second method you have bypassed the api and need to use the chipwhisper package manually as you would a python package.
I just want to make sure it is not related to you not disconnecting from the scope. Easiest way to disconnect between uses is to unplug the chipwhisperer and plug it back into the computer. Normally you would run
When running commands you just have to be careful not to try to connect to the scope when it is already in use. More information can be found on the wiki page MATLAB 4.0 api usage
Hope this helps. If you get another error just post that. Another quick question: you are still using cw 4.0?