Do you encounter incorrect results when generating plain C/C++ code, or just GPU code? Can you reproduce the issue for any simple example, or only for this particular appliation?
Resources for debugging generated MEX code can be found below:
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!