Programming by S-Function Builder is an effective way to embed algorithms. There are many comprehensive examples/tutorials provided on Internet. Before starting this post, the ‘build’ progress would be completed.
- Step1: Perform “mex -g ****.c ****_wrapper.c” in MATLAB command window, where “****” is the S-Function name.
- Step2: Open Visual Studio and choose “Attach to Process” in the TOOLS manu and select the MATLAB process.
- Step3: Open the file “****_wrapper.c” from Visual Studio, set the breakpoints at the necessary places. The breakpoints may show up with question marks. Then, run the Simulink model which includes the S-Function Block. The program will stop at the breakpoints.
- Step4: Check the variable value, which is located in the local tab at the lower part of the Visual Studio window. The algorithms can be checked step by step by F11.