Generate C code to run kinematic analysis on KinematicsSolver object




generateCode(ks) generates C code to run a kinematic analysis on the KinematicsSolver object ks. The code is specific to the object and its kinematic variables—its targets, guesses, and outputs—at the time of code generation. A MATLAB function accompanies the outputs and serves to build the code for simulation in Simulink or for deployment outside MATLAB.

The code is stored in C files with a standard H file for global declarations. The files are stored in a folder created in the MATLAB working directory and named after the model from which the KinematicsSolver object derives. The name of the folder is <modelname>_codegen_kinematics. The accompanying MATLAB function is stored in an M file placed in the MATLAB working directory under the name <modelname>_solveKinematics.m.

The MATLAB function is not to be called directly. Call the function from a MATLAB Function block to build the code for simulation. The block builds the code automatically once the simulation starts. Alternatively, pass the name of the MATLAB function as an argument to the codegen function of Simulink Coder to build the code for deployment. For example:

codegen -config:mex <MODELNAME>_solveKinematics

A Simulink Coder license is required.

Input Arguments

collapse all

Name of the KinematicsSolver object for which to run the analysis. The object is a kinematic representation of the model from which it derives. It contains the variables upon which the analysis depends.

Example: 'fourBarKS'

Data Types: char | string

Introduced in R2019a