Main Content

symType

シンボリック オブジェクトの型の決定

R2019a 以降

説明

s = symType(symObj) は、シンボリック オブジェクトの型を返します。たとえば、symType(sym('x'))"variable" を返します。

すべて折りたたむ

シンボリック数を作成し、その型を決定します。

a = sym('3/9');
s = symType(a)
s = 
"rational"

次に、シンボリック数を配列要素に含めて、シンボリック配列を作成します。各配列要素のシンボリック型を決定します。

B = [-5, a, vpa(a), 1i, pi];
s = symType(B)
s = 1x5 string
    "integer"    "rational"    "vpareal"    "complex"    "constant"

syms を使用してシンボリック関数 f(x) を作成します。

syms f(x)

関数の型を決定します。f(x) は未割り当てのシンボリック関数であるため、そのシンボリック型は "symfun" です。

s = symType(f)
s = 
"symfun"

f(x) に数式を割り当てると、そのシンボリック型が変更されます。

f(x) = x^2;
s = symType(f)
s = 
"expression"

f(x) = x のシンボリック型とその導関数を確認します。

f(x) = x;
s = symType(f)
s = 
"variable"
s = symType(diff(f))
s = 
"integer"

不等式の求解時にさまざまなシンボリック オブジェクトの型を決定します。

二次関数を作成します。

syms y(x)
y(x) = 100 - 5*x^2
y(x) = 100-5x2

2 つの不等式を二次関数に設定します。各不等式のシンボリック型を確認します。

eq1 = y(x) > 10;
eq2 = x > 2;
s = symType([eq1 eq2])
s = 1x2 string
    "equation"    "equation"

solve を使用して、不等式を解きます。'ReturnConditions'true に設定して解を返します。

eqSol = solve([eq1 eq2], 'ReturnConditions', true);
sols = eqSol.conditions
sols = x<182<x

解のシンボリック型を決定します。

s = symType(sols)
s = 
"logicalexpression"

入力引数

すべて折りたたむ

シンボリック オブジェクト。シンボリック数、シンボリック変数、シンボリック式、シンボリック関数またはシンボリック単位として指定します。

出力引数

すべて折りたたむ

シンボリック型。string 配列として返されます。次の表に、さまざまなシンボリック オブジェクトの出力値を示します。

出力説明入力の例
"integer"シンボリック整数symType(sym('-1'))
"rational"シンボリック有理数symType(sym('1/2'))
"vpareal"シンボリックな可変精度の浮動小数点実数値symType([sym('1.5') vpa('3/2')])
"complex"シンボリック複素数symType(sym('1+2i'))
"constant"シンボリック数学定数symType(sym([pi catalan]))
"variable"シンボリック変数syms x; symType(x)
"symfun"未割り当てのシンボリック関数syms f(x); symType(f)
"expression"シンボリック式syms x; symType(sqrt(x))
"equation"シンボリックな方程式および不等式syms x; symType(x>=0)
"unit"シンボリック単位symType(symunit('meter'))
"logicalexpression"シンボリックな論理式syms x y; symType(x|y)
"logicalconstant"シンボリック論理定数symType([symtrue symfalse])
"unsupported"symType でサポートされていないシンボリック オブジェクト 

バージョン履歴

R2019a で導入