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.

redumpt
  • 167
  • 13

1 Answers1

1

First, yo will need to declare the mask parameter

enter image description here

the, you will need to pass the filename to SFunction parameter

enter image description here

Last, you will use the parameter inside the sfunction, like this:

 mxGetPr(ssGetSFcnParam(S,0));

See:

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

guilhermecgs
  • 2,913
  • 11
  • 39
  • 69
  • I think to accept parameter from mask i.e array of char inside s function i need to use int mxGetString(const mxArray *pm, char *str, mwSize strlen); method ...Thanx for the help :) – redumpt Oct 14 '15 at 09:19
  • I didn't test the solution by myself, so you are probably correct. I just gave you the direction to follow. Let me know if it works. May the force be with you :-) – guilhermecgs Oct 14 '15 at 12:22
  • i followed your suggested procedure but to get parameter value i used mxGetString ....It's Working .Thanx for the help:) – redumpt Oct 14 '15 at 12:34