0

I have an C mex S function which can print output to the .txt file. This code inside mdlStart(SimStruct *S) creates datafile.txt file and appends the output.

  void** pwork = ssGetPWork(S);
  FILE *datafile;

  datafile = fopen("datafile.txt","a");
  pwork[0] =  datafile;

So now I want to dynamically get the filename of .txt file from user through S function mask . so , How can I receive string value of filename from mask inside S function.

4

1 回答 1

1

首先,你需要声明掩码参数

在此处输入图像描述

,您需要将文件名传递给 SFunction 参数

在此处输入图像描述

最后,您将在 sfunction 中使用参数,如下所示:

 mxGetPr(ssGetSFcnParam(S,0));

看:

http://www.mathworks.com/help/simulink/sfg/ssgetsfcnparam.html http://www.mathworks.com/matlabcentral/answers/36028-integer-parameters-to-c-mex-s-function

于 2015-10-13T19:15:21.683 回答