How do I use the FOPEN function in Embedded MATLAB when running in Rapid Accelerator mode in Simulink 7.7 (R2008b)?
4 次查看(过去 30 天)
显示 更早的评论
I am using the Embedded MATLAB Function block in my model to perform some calculations. I am writing some intermediate data to a text file using the FOPEN, FPRINTF and FCLOSE commands. Since these commands are not inherently supported with EML, I am using the eml.extrinsic construct to use these functions. The model runs fine in Normal and Accelerator modes but gives the following error message when run in Rapid Accelerator mode:
Failed to eliminate a use of the MATLAB function 'fopen'. For non-simulation builds, uses of unsupported MATLAB functions are eliminated if they do not effect the function outputs.
Function 'Embedded MATLAB Function' (#39.225.256), line 12, column 10:
"fopen('pointScorefile.txt','w')"
A sample model (trial_fopen.mdl) is attached.
采纳的回答
MathWorks Support Team
2009-6-27
The error occurs because the FOPEN function is not supported for code generation. The Rapid Accelerator mode works only with those models containing blocks that support code generation of a standalone executable.
To work around the issue, you can use eml.ceval to evaluate an external C function (which performs the file handling operations).
The demo ("Embeddable C-Code Generation Using Embedded MATLAB Coder") illustrates how this can be accomplished. In R2008b, this demo can be found by executing the following at the MATLAB command prompt:
web([matlabroot '/toolbox/rtw/rtwdemos/html/rtwdemo_emlcbasicdemo.html'], '-helpbrowser')
A working model (trial_fopen_c.mdl) can be found in the attachments.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Prepare Model Inputs and Outputs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!