by An Uncommon Lab


Here we discuss *kf's options for generating code and other tools to assist in the integration of the filters into the appropriate environments.

Output Directory

Select where all of the generated files should be stored. By default, this is the working directory. Clicking on the button allows the user to select any other directory.

When saving a configuration, the engine will ask if the path to the output directory should be saved as an absolute path or as a path relative to the location of the saved file. The latter is especially useful when saving configurations as part of a shared code repository.

Header Comments

Text entered here will appear in the header comment of all generated files. There's no need to enter comment characters explicitly.

Code Generation Language

Currently, *kf only generates MATLAB code.

Generate ML-to-C Builder?

If selected, *kf will generate a function to convert the generated filter to C code using MATLAB Coder. This file can be generated at any time, but it can only be executed if MATLAB Coder is installed.

When the code is generated, it is generated as portable, ANSI C code and can be used in any project, requiring no additional libraries or any additional code.

Generate Simulink Block?

If selected, a Simulink block will be generated which wraps the filter code. The block will use an Embedded MATLAB block (which, as of newer versions, is now called a MATLAB Function block). Any constant inputs to the filter will be placed in constant blocks, and the generated constants struct, if used by the filter, will have a corresponding Simulink Bus Object defined in the workplace.

Naturally, generating the block requires Simulink.

Generate MEX?

If selected, *kf will generate a function to automatically convert the generated filter to C code and on to a MEX file. Executing this file requires MATLAB Coder and, if present, *kf will build the MEX directly. If the build is successful, the generated example simulation will use the MEX file instead of the MATLAB version of the filter.

MEX files can run substantially faster than the corresponding MATLAB code, so for filters that will be used frequently within MATLAB, generating the MEX is a good idea.

Naturally, any functions called by the filter, such as the user's propagation function, will need to be codegen-compliant for the MEX compilation to work. Therefore, only use this options if you are familiar with codegen-compliant MATLAB code (see the MATLAB Coder documentation).

Open Generated Files?

Check this box to have all of the generated files automatically opened once generated. Though on by default, most users will probably turn this off after they become comfortable with the generated code.