codegen: can I use a Matlab global structure in a mex function created with codegen?
古いコメントを表示
I have a global structure S defined in my Matlab function and I use it in another function I want to compile with coder. Is it possible? How can I tell the coder that S is a Matlab structure? Example:
File function_1.m:
function_1
global S
S = struct ('a', 0);
File function_2.m:
function_2 %#codegen
global S
x = S.a + 2;
If I compile function_2.m the coder notify an error; how can I do?
採用された回答
その他の回答 (1 件)
Kaustubha Govind
2012 年 11 月 19 日
I wonder if you should do something like:
function_2 %#codegen
global S
if isempty(S)
S = struct ('a', 0);
end
x = S.a + 2;
2 件のコメント
Giuela
2012 年 11 月 19 日
Kaustubha Govind
2012 年 11 月 19 日
Is 'S' defined in the MATLAB workspace at this point? It looks like your original definition should have worked according to Generate C Code from Code Containing Global Data
カテゴリ
ヘルプ センター および File Exchange で Algorithm Design Basics についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!