M-File Help: ccodefunctionstring | View code for ccodefunctionstring |
Converts a symbolic expression into a C-code function
[funstr, hdrstr] = ccodefunctionstring(symexpr, arglist) returns a string representing a C-code implementation of a symbolic expression symexpr. The C-code implementation has a signature of the form:
void funname(double[][n_o] out, const double in1,
const double* in2, const double[][n_i] in3);
depending on the number of inputs to the function as well as the dimensionality of the inputs (n_i) and the output (n_o). The whole C-code implementation is returned in funstr, while hdrstr contains just the signature ending with a semi-colon (for the use in header files).
'funname', name | Specify the name of the generated C-function. If this optional argument is omitted, the variable name of the first input argument is used, if possible. |
'output', outVar | Defines the identifier of the output variable in the C-function. |
'vars', varCells | The inputs to the C-code function must be defined as a cell array. The elements of this cell array contain the symbolic variables required to compute the output. The elements may be scalars, vectors or matrices symbolic variables. The C-function prototype will be composed accoringly as exemplified above. |
'flag', sig | Specifies if function signature only is generated, default (false). |
% Create symbolic variables syms q1 q2 q3
Q = [q1 q2 q3]; % Create symbolic expression myrot = rotz(q3)*roty(q2)*rotx(q1)
% Generate C-function string [funstr, hdrstr] = ccodefunctionstring(myrot,'output','foo', ... 'vars',{Q},'funname','rotate_xyz')
Joern Malzahn, (joern.malzahn@tu-dortmund.de)
© 1990-2014 Peter Corke.