Documentation

# Code Generation

Use symbolic results in MATLAB®, Simulink®, Simscape™, C, Fortran, and LaTeX

The results of symbolic computations are often used in numeric codes that exclusively use standard double-precision arithmetic. Symbolic Math Toolbox™ provides functions for generating MATLAB functions, Simulink Function blocks, and equations based on the Simscape language – directly from symbolic expressions.

With these functions, you can convert the result of your symbolic computations into functions based on numeric computation, ready to be used in other parts of your program. Using the generated MATLAB functions does not require a license for Symbolic Math Toolbox. You can also convert symbolic expressions into C, Fortran, MathML, and TeX code.

## Functions

expand all

 `matlabFunction` Convert symbolic expression to function handle or file `matlabFunctionBlock` Convert symbolic expression to MATLAB function block
 `simscapeEquation` Convert symbolic expressions to Simscape language equations `symReadSSCParameters` Load parameters from Simscape component `symReadSSCVariables` Load variables from Simscape component `symWriteSSC` Create new Simscape component
 `ccode` C code representation of symbolic expression `fortran` Fortran representation of symbolic expression `latex` LaTeX form of symbolic expression `mathml` Generate MathML from symbolic expression `texlabel` TeX representation of symbolic expression

## Topics

Generate C or Fortran Code from Symbolic Expressions

Convert symbolic expressions to C or Fortran code.

Generate MATLAB Functions from Symbolic Expressions

Convert symbolic expressions to MATLAB functions that accepts numeric values.

Generate MATLAB Function Blocks from Symbolic Expressions

Convert symbolic expressions to Simulink blocks.

Generate Simscape Equations from Symbolic Expressions

Translate results of symbolic computations to Simscape language equations.

## Featured Examples

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos
{"ft_lang_label":"__label__en","ft_lang_prob":0.7479793,"math_prob":0.90550756,"size":1126,"snap":"2019-35-2019-39","text_gpt3_token_len":202,"char_repetition_ratio":0.19875222,"word_repetition_ratio":0.059210528,"special_character_ratio":0.1545293,"punctuation_ratio":0.093023255,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9941104,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-21T07:03:47Z\",\"WARC-Record-ID\":\"<urn:uuid:1c8954e8-2693-4e20-a2c4-2cc890d6ec2d>\",\"Content-Length\":\"73918\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:328cb348-2a35-49cd-8dd6-3237eee5ff87>\",\"WARC-Concurrent-To\":\"<urn:uuid:7a2fc20a-c67d-46e4-8085-4b60291d83c7>\",\"WARC-IP-Address\":\"23.48.45.75\",\"WARC-Target-URI\":\"https://it.mathworks.com/help/symbolic/code-generation.html\",\"WARC-Payload-Digest\":\"sha1:XL2UNSJ3XANEK2EBHF7VQ2BEOEXY5MPE\",\"WARC-Block-Digest\":\"sha1:GZ6W6HFAE6ZONJU5GGZVH2QAA7HZBREF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514574286.12_warc_CC-MAIN-20190921063658-20190921085658-00421.warc.gz\"}"}