MatLab Coder - MatLab to C

断了今生、忘了曾经 提交于 2019-12-12 06:15:37

问题


I am trying to run MatLab Coder to transform a matlab .m file into .mex to hopefully run the code more quickly. When trying to build the file via MatLab Coder engine, I get the following error:

Undefined function or variable 'k'. The first assignment to a local variable determines its class.

k is determined inside a previous loop. My guess is that C code cannot "remember" values inside an earlier loop. How can I come around this?

Any help is appreciated.

Thanks.


回答1:


Since all of "Undefined function or variable" errors were on variables, and all variables were 1 x 1 doubles, you have to just define them all as 0 prior to them being defined in a for loop. It seems you can not define them in a for loop.



来源:https://stackoverflow.com/questions/29720498/matlab-coder-matlab-to-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!