Use the debugger to stop, when a NaN occurs:
Type this in the command window. Now run the code again until it stops at the first occurring NaN. Now you can check the current values.
By the way, in older Matlab versions clear all cleared the debugger status also. Everything which impedes debugging is an enemy of the programmer. Therefore I strongly recommend to omit this brute clearing, which wastes time only. Prefer to use functions, if you want to keep the workspace clean.
Defining the function to be integrated by a char vector is outdated for 15 years now, but supported for backward compatibility. Use a function handle instead: