mex file gives two different results. what is the cause?
2 次查看(过去 30 天)
显示 更早的评论
Hello, I am running a mex file that i compiled on my pc. I expect that for the same input the result would be the same. however, this is not the case - the first and second runs (for the same input) give completely diferent results. I am lost and dont know even what to look for. does anyone know what could be the cause of this abnormal phenomena?
0 个评论
回答(2 个)
Honglei Chen
2016-7-27
maybe you have some random number in functions you use? Could you try to run
rng(0)
before each run of your script and see if it still produces different results?
2 个评论
Honglei Chen
2016-7-28
I'm wondering if you updated the global variable in your first run but didn't reinitialize it in the second run? Maybe you can try the "clear" command between each run to see if that's the case?
Walter Roberson
2016-7-27
You are probably either corrupting memory or using uninitialized memory.
2 个评论
Walter Roberson
2016-7-27
Did you declare the variable as global in every routine you use it in? You need to specifically "global" the variable in each function you want to use the value in.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!