主要内容

mathml

从符号表达式生成MathML

Description

example

chr= mathml(f)returns the generated MathML from the symbolic expressionf.

example

chr= mathml(f,Name,Value)uses additional options specified by one or more name-value pair arguments. For example, generate MathML for inline display by specifyingDisplayInlineas真正.

Examples

collapse all

Generate MathML from a symbolic expression.

syms x f = 1/exp(x^2); chr = mathml(f)
装备= ' <垫h xmlns='http://www.w3.org/1998/Math/MathML' display='block'>    -  x 2     '

Generate MathML for inline display by specifyingDisplayInlineas真正.

syms x f = 1/exp(x^2); chr = mathml(f,'DisplayInline',true)
chr ='  &ee;     -     x   2     '
                    
                   
                  
                 
                
               
              
             
             

使用MathML工具提示为单位和某些特殊功能提供更多信息。通过指定生成工具提示工具提示as真正.

syms nu x f = besselj(nu,x); chr = mathml(f,'Tooltips',true)
装备= ' <垫h xmlns='http://www.w3.org/1998/Math/MathML' display='block'>    J besselj  ν   ( x )    '

When you use MathML in a web page, then pausing onJ显示一个包含的工具提示besselj.

Modify generated MathML by setting symbolic preferences using thesympreffunction.

Generate the MathML form of the expressionπwith the default symbolic preference.

sympref('default'); chr = mathml(sym(pi))
装备= ' <垫h xmlns='http://www.w3.org/1998/Math/MathML' display='block'> π  '

Set the'FloatingPointOutput'preference to真正to return symbolic output in floating-point format. Generate the MathML form ofπin floating-point format.

sympref('FloatingPointOutput',true); chr = mathml(sym(pi))
chr ='  3.1416  '
                    
                   
                  
                  

Now change the output order of a symbolic polynomial. Create a symbolic polynomial and set'PolynomialDisplayStyle'preference to'ascend'. Generate MathML form of the polynomial sorted in ascending order.

syms x; poly = x^2 - 2*x + 1; sympref('PolynomialDisplayStyle','ascend'); chr = mathml(poly)
装备= ' <垫h xmlns='http://www.w3.org/1998/Math/MathML' display='block'>  1 -  2  x  +  x 2    '

The preferences you set usingsymprefpersist through your current and future MATLAB®sessions. Restore the default values by specifying the'默认'选项。

sympref('default');

输入Arguments

collapse all

输入, specified as a symbolic number, variable, array, function, or expression.

Name-Value Pair Arguments

Specify optional comma-separated pairs ofName,Valuearguments.Nameis the argument name and是相应的价值。Namemust appear inside quotes. You can specify several name and value pair arguments in any order asname1,value1,...,namen,valuen.

Example:mathml(f,'Tooltips',true)

Inline MathML display, specified as the comma-separated pair consisting of'DisplayInline'and either真正要么false(default).

工具提示in MathML output, specified as the comma-separated pair consisting of'Tooltips'and either真正要么false(default).mathmladds tooltips for units and some special functions.

Introduced in R2018b