The real() command outputs a complex number (doesn't appear to change it).

6 ビュー (過去 30 日間)
Patrick Coelen
Patrick Coelen 2023 年 1 月 20 日
編集済み: Paul 2023 年 1 月 21 日
I want to evaluate the real part of some eigenvalues, but real(eigen) just returns eigen (isreal(real(eigen) returns 0).
  2 件のコメント
Stephen23
Stephen23 2023 年 1 月 21 日
編集済み: Stephen23 2023 年 1 月 21 日
Why do you imagine that ISREAL() can be applied to symbolic variables? It is not listed as a function of the symbolic toolbox:
and the ISREAL() documentation clearly states that it checks "whether array uses complex storage", i.e. it checks for something that is purely a characteristic of numeric arrays and has nothing to do with symbolic mathematics. See:
In contrast, REAL() is a function of the symbolic toolbox, and works exactly as described:
Paul
Paul 2023 年 1 月 21 日
編集済み: Paul 2023 年 1 月 21 日
Just because a function is not listed as a function of the symbolic toolbox in its documentation does not mean that function can't be applied to a sym variable. We can further break this situation down into two cases.
First, functions that are not methods of the syms class, but work fine on sym objects because the underlying code in the function all works on sym. The function dot is a good example
x = sym('x',[1 3])
x = 
dot(x,x)
ans = 
Second, some methods of the sym class (at least one, I can't say for sure more than one) are just not documented. For example, exp is a sym method, but is (shockingly, IMO) not listed as a function of the symbolic toolbox on that linked page.
exp(x)
ans = 
More discussion here

サインインしてコメントする。

採用された回答

Torsten
Torsten 2023 年 1 月 20 日
isreal(real(double(eigen(t))))
instead of
isreal(real(eigen(t)))

その他の回答 (1 件)

Paul
Paul 2023 年 1 月 21 日
In syms world, use isAlways to determine if an expression or variable is real, etc.
syms x
isAlways(in(x,'real'))
Warning: Unable to prove 'in(x, 'real')'.
ans = logical
0
assume(x,'real')
isAlways(in(x,'real'))
ans = logical
1
  1 件のコメント
Stephen23
Stephen23 2023 年 1 月 21 日
+1 for giving the correct symbolic solution.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by