Simulink SFunction Interface Error: due to insufficient storage

1 回表示 (過去 30 日間)
legendbb
legendbb 2012 年 7 月 13 日
Very simple function block, with matrices input and constants total less than 80MB. Sample time 1, Simulation Duration 2. Code runs as a snap in Matlab. Moved into a system model failed in compilation (Xp 32-bit, 4GB) with error:
MATLAB Function Interface Error: Error calling generated SFunction, test_sfun, due to insufficient storage. This is most likely due to large static arrays in the generated code. Disabling debugging may help.
Same model compile and run perfectly on: Win7 x64 Matlab x64 8GB system
Can anyone please comment on this, the model has a keyword: simple.
Or maybe there is an SFuntion design criteria I should have read.
Thanks,

回答 (3 件)

Fred Smith
Fred Smith 2012 年 7 月 18 日
Have you tried turning off debugging in the MATLAB Function block? That usually has a dramatic effect and allows many more examples to work.
  1 件のコメント
legendbb
legendbb 2012 年 7 月 20 日
Thanks for your comment, that's the first thing I did following the hints in the error message.

サインインしてコメントする。


legendbb
legendbb 2012 年 7 月 20 日
編集済み: legendbb 2012 年 7 月 20 日
I've given up to have matrix manipulation on x32 bit machine. The model works fine on x64.
On x32 machine, I turned to do process row by row. As long as I don't introduce enable signal or gaps between row. It works fine. Just trade it with the simulation time to vector length.
  1 件のコメント
Kaustubha Govind
Kaustubha Govind 2012 年 7 月 23 日
Thanks for posting your solution!

サインインしてコメントする。


Kaustubha Govind
Kaustubha Govind 2012 年 7 月 16 日
Are you using the (Embedded) MATLAB Function block to bring your MATLAB code into Simulink? The MATLAB Function block generates C-code from the MATLAB code before executing it (and runs it via a C-MEX S-function), so it is slightly different from running the code directly in MATLAB. Perhaps 80MB is too large for the program stack on 32-bit Windows. You could try converting your large data into global variables and see if that helps. Please see Using Global Data with the MATLAB Function Block for more information.
  2 件のコメント
legendbb
legendbb 2012 年 7 月 16 日
Thank you for your recommendation.
I've removed %#codgen from the original code. don't know if it removes the Embedded property, I don't need the block to be turned into any hardware, just need calculation result for reference.
I had turned almost everything into global. Still won't work (same error). Inside the function I attempted [1024 8192] array element wise (add/subtract/multiply). Considering stack size limit for functional block, it makes sense for not working.
But what is the stack size limit? Is it documented somewhere? If I am not able to run this Matlab function in simulink, I am thinking about segmenting the original matrix to process row by row.
Am I looking at the right direction?
Thanks again,
Kaustubha Govind
Kaustubha Govind 2012 年 7 月 17 日
The %#codegen doesn't change anything about the functioning of the block - AFAIK, it is mostly used only for M-Lint analysis to check your code for code-generation compatibility. I'm not sure what the program stack limit is - I'm guessing it changes by platform and the selected MEX compiler?
If you don't want C code to be generated, you might want to use the Interpreted MATLAB Function block instead - note that this block only allows for one input and one output.
Actually, I'm not sure if the memory issue is specific to the Embedded MATLAB Function block, or to Simulink, but the Interpreted MATLAB block is worth a try.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel Verification についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by