-
Notifications
You must be signed in to change notification settings - Fork 1
Creating a program
A typical STL program comprises a file user.m which contains the "main" thread of execution which is executed when the binary is launched.
The codegen build is defined by a supplied MATLAB script make.m. You need to edit this file to suit your build. The bulk of this file is concerned with setting up the codegen and build parameters. The last line describes the files that comprise your application and should be changed to suit.
codegen user.m thread1.m -args int32(0) thread2.m -config cfgThe first file listed should be user.m which has the "main" code for your application. It is called at run time.
After this you should list any other files that contain thread definitions. Each of these looks like a regular MATLAB function definition file where function.m defines a MATLAB function function that has no return values and has at most one argument.
If the thread has no arguments, just list its name on the codegen line, like thread2.m in the example above.
If the thread has an argument, list its name on the codegen line, like thread1.m in the example above. It must be followed by -args to inform codegen what kind of argument it expects. At the moment only int32 is supported.
Now run the make script make.m
>> makeand if there were no compilation or link errors, there will be an executable file user in the current directory which we can run
% ./userIntermediate C and object files will be generated in the local folder codegen/exe/user.
- Threads will often be infinite loops and
codegenwill complain about them, ignore the warning
Warning: Function 'thread3' does not terminate due to an infinite loop.
-
If there are errors regarding
main.c,stl.corstl.hensure that the folderstlis in your MATLAB path. -
Any other errors will yield a report like
Error in ==> user Line: 7 Column: 38
Code generation failed: View Error Report
Click on the hyperlink to open the report, the BuildLog tab is the most useful part, and fix your error(s).
There's no need to put a semicolon on the end of each line. The generated code won't print the result of the line.