Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

generate::MathML

Generate MathML from expressions

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

generate::MathML(expr, options)

Description

generate::MathML(expr) returns the MathML code representing expr. To print this code to a file, use fprint.

Examples

Example 1

Generate the MathML code from the following expression. Use hold to prevent evaluation of the integral. By default, generate::MathML returns both Presentation and Content MathML, and includes annotations.

generate::MathML(hold(int)(exp(x^2)/x, x))
<math xmlns='http://www.w3.org/1998/Math/MathML'>
  <semantics>
    <mrow>
      <mo form='prefix'>&Integral;</mo>
      <mrow/>
      <mfrac>
        <msup>
          <mo>&ee;</mo>
          <msup>
            <mi>x</mi>
            <mn>2</mn>
          </msup>
        </msup>
        <mi>x</mi>
      </mfrac>
      <mo form='infix'>&DifferentialD;</mo>
      <mi>x</mi>
    </mrow>
    <annotation-xml encoding='MathML-Content'>
      <apply>
        <int/>
        <bvar>
          <ci>x</ci>
        </bvar>
        <apply>
          <divide/>
          <apply>
            <exp/>
            <apply>
              <power/>
              <ci>x</ci>
              <cn type='integer'>2</cn>
            </apply>
          </apply>
          <ci>x</ci>
        </apply>
      </apply>
    </annotation-xml>
    <annotation encoding='MuPAD'>
      int(exp(x^2)/x, x)
    </annotation>
  </semantics>
</math>

Example 2

Show only the Presentation MathML part of the output by setting Content to FALSE.

generate::MathML(hold(int)(exp(x^2)/x, x), 
                         Content = FALSE)
<math xmlns='http://www.w3.org/1998/Math/MathML'>
  <semantics>
    <mrow>
      <mo form='prefix'>&Integral;</mo>
      <mrow/>
      <mfrac>
        <msup>
          <mo>&ee;</mo>
          <msup>
            <mi>x</mi>
            <mn>2</mn>
          </msup>
        </msup>
        <mi>x</mi>
      </mfrac>
      <mo form='infix'>&DifferentialD;</mo>
      <mi>x</mi>
    </mrow>
    <annotation encoding='MuPAD'>
      int(exp(x^2)/x, x)
    </annotation>
  </semantics>
</math>

Show only the Content MathML part of the output by setting Presentation to FALSE.

generate::MathML(hold(int)(exp(x^2)/x, x), 
                    Presentation = FALSE)
<math xmlns='http://www.w3.org/1998/Math/MathML'>
  <semantics>
    <apply>
      <int/>
      <bvar>
        <ci>x</ci>
      </bvar>
      <apply>
        <divide/>
        <apply>
          <exp/>
          <apply>
            <power/>
            <ci>x</ci>
            <cn type='integer'>2</cn>
          </apply>
        </apply>
        <ci>x</ci>
      </apply>
    </apply>
    <annotation encoding='MuPAD'>
      int(exp(x^2)/x, x)
    </annotation>
  </semantics>
</math>

Suppress annotations by setting Annotation to FALSE.

generate::MathML(hold(int)(exp(x^2)/x, x), 
                      Annotation = FALSE)
<math xmlns='http://www.w3.org/1998/Math/MathML'>
  <semantics>
    <mrow>
      <mo form='prefix'>&Integral;</mo>
      <mrow/>
      <mfrac>
        <msup>
          <mo>&ee;</mo>
          <msup>
            <mi>x</mi>
            <mn>2</mn>
          </msup>
        </msup>
        <mi>x</mi>
      </mfrac>
      <mo form='infix'>&DifferentialD;</mo>
      <mi>x</mi>
    </mrow>
    <annotation-xml encoding='MathML-Content'>
      <apply>
        <int/>
        <bvar>
          <ci>x</ci>
        </bvar>
        <apply>
          <divide/>
          <apply>
            <exp/>
            <apply>
              <power/>
              <ci>x</ci>
              <cn type='integer'>2</cn>
            </apply>
          </apply>
          <ci>x</ci>
        </apply>
      </apply>
    </annotation-xml>
  </semantics>
</math>

Example 3

Generate MathML code from the following expression and write the result to filename.mathml by using fprint.

fprint(Text, "filename.mathml", 
       generate::MathML(hold(int)(exp(x^2)/x, x))):

Parameters

expr

Arithmetical expression

Options

Annotation

Option, specified as Annotation = FALSE.

Suppresses the output of annotations.

Content

Option, specified as Content = FALSE.

Suppresses the MathML Content part of the output.

Presentation

Option, specified as Presentation = FALSE.

Suppresses the MathML Presentation part of the output.

Return Values

generate::MathML returns an object containing MathML code.

Overloaded By

expr

See Also

MuPAD Functions

Was this topic helpful?