How do I write data from a C-MEX S-function into a file?

I would like to write data from a C-MEX S-function into a file.

 Accepted Answer

There is an example model and an S-function that you can download below.
You will have to compile the S-function using the following command:
mex fileout2.c
This example file will write every 10th data point to the file. A DWork vector is used to keep count of the number of data points.You should take a look at the mdlStart Callback that opens a file and then gets a pointer to the file. You should also take a look at the mdlTerminate Callback that will close the file.

More Answers (0)

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!