How do I use the FOPEN function in Embedded MATLAB when running in Rapid Accelerator mode in Simulink 7.7 (R2008b)?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
MathWorks Support Team
am 27 Jun. 2009
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Prepare Model Inputs and Outputs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!