initialize persistent variables using Matlab coder
My Matlab code utilizes a few persistent variables and currently uses "isempty" for one of the variables to ensure all are intialized before use. The resulting Matlab coder initialization function sets a bool "var_isempty". This seems rather clunky. To me it seems that the appropriate coder output should instead initialize the values in the static variable definition within the function.
Is there a codegen option to generate the code in this manner? Or another way?
The https://www.mathworks.com/help/coder/ug/use-generated-initialize-and-terminate-functions.html refers to both global and persistent variables witht the -global option. Is this the best method?My Matlab code utilizes a few persistent variables and currently uses "isempty" for one of the variables to ensure all are intialized before use. The resulting Matlab coder initialization function sets a bool "var_isempty". This seems rather clunky. To me it seems that the appropriate coder output should instead initialize the values in the static variable definition within the function.
Is there a codegen option to generate the code in this manner? Or another way?
The https://www.mathworks.com/help/coder/ug/use-generated-initialize-and-terminate-functions.html refers to both global and persistent variables witht the -global option. Is this the best method? My Matlab code utilizes a few persistent variables and currently uses "isempty" for one of the variables to ensure all are intialized before use. The resulting Matlab coder initialization function sets a bool "var_isempty". This seems rather clunky. To me it seems that the appropriate coder output should instead initialize the values in the static variable definition within the function.
Is there a codegen option to generate the code in this manner? Or another way?
The https://www.mathworks.com/help/coder/ug/use-generated-initialize-and-terminate-functions.html refers to both global and persistent variables witht the -global option. Is this the best method? matlab coder, persistent variables, initialization MATLAB Answers — New Questions